1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
| a = np.zeros((2,2)) print(a)
out: [[ 0. 0.] [ 0. 0.]]
b = np.ones((1,2)) print(b)
out: [[ 1. 1.]]
c = np.full((2,2), 7) print(c)
out: [[7 7] [7 7]]
d = np.eye(2) print(d)
out: [[ 1. 0.] [ 0. 1.]]
d_1 = np.diag([10,20,30,50]) print(d_1)
out: [[10 0 0 0] [ 0 20 0 0] [ 0 0 30 0] [ 0 0 0 50]]
e = np.arange(15) print(e)
out: [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14]
e_1 = np.arange(4,10) print(e_1)
out: [4 5 6 7 8 9]
e_2 = np.arange(1,14,3) print(e_2)
out: [ 1 4 7 10 13]
f = np.linspace(0,10,6) print(f)
out:
[ 0., 2., 4., 6., 8., 10.]
g = np.arange(12).reshape(3,4) print(g)
out:
[[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11]]
h = np.random.random((2,2)) print(e)
out: [[ 0.72776966 0.94164821] [ 0.04652655 0.2316599 ]]
i = np.random.randint(4,15,size = (2,2)) print(i)
out: [[6, 5], [5, 9]]
j = np.random.normal(0,0.1,size = (3,3)) print(j)
out: [[-0.20783767, -0.12406401, -0.11775284], [ 0.02037018, 0.02898423, -0.02548213], [-0.0149878 , 0.05277648, 0.08332239]]
|