1 #1.回文数 2 number = input("请输入数字:") 3 r-num = number[::-1] 4 if number == r-num : 5 print(f"{number}是回文数") 6 ####################### 7 #2.水仙花 8 for i in range(100,1000): 9 a = i // 100 10 b = i //10 % 10 11 c = i %10 12 if i == a**3 + b**3 + c**3: 13 print(f"{i}是水仙花数") 14 15 ######################## 16 num = input() 17 lenth = len(n) 18 if sum(map(lambda x:int(x)**lenth ,num)) == int(num): 19 print("Y") 20 else: 21 print("N") 22 #3.10*10矩阵,边界全1,中间全0 23 import numpy as np 24 A = np.zeros((10,10)) 25 A[:,9]=1 26 A[:,0]=1 27 A[0,:]=1 28 A[9,:]=1 29 print(A) 30 ########################### 31 #4.矩阵对角线 32 import numpy as np 33 B = np.diag([1,2,3,4,5,6,7,8,9,10]) 34 print(B) 35 ########################### 36 #5.矩阵计算 37 import numpy as np 38 C = np.dot(A,B) 39 print(C) 40 ############################ 41 #6.矩阵特征值,特征向量 42 import numpy as np 43 D = np.array([[1,2],[3,4]]) 44 D_W,D_V = np.linalg.eig(D) 45 print(D_W) 46 print(D_V) 47 #########################