Skip to content

Commit ff2651e

Browse files
committed
Intro and Basics of Numpy
1 parent 5c6eb34 commit ff2651e

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Numpy/P01_Introduction.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,27 @@
5757

5858
# to check the data we have dtype.
5959
print(myArray.dtype) # int64
60+
61+
# zeros creates an array will all zeros
62+
myArray = np.zeros((3, 4))
63+
print(myArray)
64+
65+
# [[ 0.  0.  0.  0.]
66+
#  [ 0.  0.  0.  0.]
67+
#  [ 0.  0.  0.  0.]]
68+
69+
# ones creates an array with all ones
70+
myArray = np.ones((3, 4))
71+
print(myArray)
72+
73+
# [[ 1.  1.  1.  1.]
74+
#  [ 1.  1.  1.  1.]
75+
#  [ 1.  1.  1.  1.]]
76+
77+
# numpy random module helps to initialize array with random values
78+
myArray = np.random.rand(3, 4)
79+
print(myArray)
80+
81+
# [[ 0.54808903  0.08750717  0.23886267  0.93589283]
82+
#  [ 0.90750146  0.31197039  0.54013725  0.91092763]
83+
#  [ 0.38827674  0.04647878  0.15997665  0.94909537]]

0 commit comments

Comments
 (0)