You are on page 1of 4

5.

The dt ype attribute of the NumPy array ob ject returns the arraydat type

123| import numpy as np


a = np.zeros((3, 3), dtype = int )
print (a)
b= np. ones ((3,3), dtype = int )
print (b)

[[1 1 1]
[1 11]
[1 1 1]1
a np.array((1,2,3,4,5,6, 7,8, 9|)
for i in a:
print (i)
1
2
3
4
L! 1.Numpy isla python library that provides qultidimensional, array objects.

2.Numpy can be used to perform 4 variety of mathematical operations on arrays.

34Less memory usage and Less execution time

importinumpy as np
ane-array( R41)
pint(10arhay is a)
31, [4,5,6j|)
print (2D array
GFAarray(
Print(
1D arrayl is
2D arnay is: iL12 )

3D arnay is 21
[4 5 6]
iotie Intro Last Checkpoint: 4 minutes ago
Ldit View Run Kernel Settings Help
+ XD Code
[21]

461: mport numpy as np


a np.random.randint(0,9,(55))
print(a)
print(a[2,:])
print (a[4,:1)
[(3 7 3 8 5]
[1 4 5 7 5]
[O.6 5 2]
2 572 1]
[4 7 3 5])
[ 6 5 2]
[4 7 3 e 5]

O Type here to search


genie Intro Lat cbe kgoint: 4ninutes ago
VIL:w Run Kernel Settings Help
+ Code

37|: import numpy as np


x= np.random.randint (0,9, (5, 5))
print(x)
xImin, xmax = .min(), x. max()
print ("Minimum and Maximum Values:"xmin, xinax)

[[3 6 4 2]
(5 7 3 5 1]
[5 0 2 1 2]
[5 5 3 2 4]
[7 0 3 1 5]]
Minimum and Maximum Values: 07

471: import numpy as np


a = np.random.randint (0,9, (4,4))
print (a)
b= a. reshape (8,2)
print (b)
C= a.reshape(2,8)
print(c)
d = a.reshape(1,16)
print (d)
Oh

J Type here to search

You might also like