Page 292 - Ai_C10_Flipbook
P. 292
%
[1]: import numpy as np
(Remainder of marks1 = np.array([10,20,30,40])
division)
marks2=np.array([1,2,3,4])
print(marks1%marks2)
print("remainder of division:",marks1%3)
[0 0 0 0]
remainder of division: [1 2 0 1]
Some Important Functions
Type Function Example
Type of an object type(ARR)
[1]: import numpy as np
i.e. array
ARR = np.array([1,2,3,4])
print(type(ARR))
<class 'numpy.ndarray'>
Check the ARR.ndim
[1]: import numpy as np
dimensions of
ARR = np.array([[1,2,3,4],[3,4,5,6]])
an array print(ARR.ndim)
2
Shape of an array ARR.shape
[1]: import numpy as np
i.e. length of the
ARR = np.array([[1,2,3,4],[3,4,5,6]])
array dimensions
print(ARR.shape)
(2, 4)
Size of an array ARR.size
[1]: import numpy as np
i.e. counts the
ARR = np.array([[1,2,3,4],[3,4,5,6]])
number of print(ARR.size)
elements
8
Datatype of ARR.dtype
[1]: import numpy as np
elements stored
ARR = np.array([[1,2,3,4],[3,4,5,6]])
in the array
print(ARR.dtype)
int32
Maximum value ARR.max()
[1]: import numpy as np
in the element
ARR = np.array([[10,34,45,23,12]])
of the array
print(ARR.max())
45
290 Artificial Intelligence Play (Ver 1.0)-X

