建立一个新矩阵,并按要求输出
其他问答
1
如图,建立一个新矩阵,并按要求输出,该问题如何解决?求答案和源代码,感激不尽。
-
import numpy as np # 全0矩阵 a = np.zeros((3, 3)) print(a) # 全1矩阵 b = np.ones((4, 5)) print(b) # 单位矩阵 c = np.eye(4) print(c) # 随机矩阵 d = np.random.randint(0, 10, (3, 2)) print(d) print(type(a[0, 0])) print(type(b[0, 0])) print(type(d[0, 0]))
-
import random a = [[0 for n in range(3)] for n in range(3)] print(a) b = [[1 for n in range(5)] for n in range(4)] print(b) d = [[random.random() for n in range(2)] for n in range(3)] print(d) print(type(a[0][0]))
发表回复