Professional Documents
Culture Documents
Experiment No. 10 - Roll No. 19-PRN No. 191041025 - Nikhil Nagesh Gosavi
Experiment No. 10 - Roll No. 19-PRN No. 191041025 - Nikhil Nagesh Gosavi
1. ndarray.ndim()
Program:
import numpy as geek
arr = geek.array([1, 2, 3, 4])
gfg = arr.ndim
print (gfg)
Result:
2. ndarray.shape()
Program:
import numpy as np
arr = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])
print(arr.shape)
Result:
3. ndarray.size()
Program:
import numpy as np
arr = np.array([[1, 2, 3, 4], [5, 6, 7, 8]])
print(np.size(arr))
Result:
Nikhil Nagesh Gosavi PRN No-191041025 Roll No-19
4. ndarray.dtype()
Program:
import numpy as np
dt = np.dtype('>i4')
print("Byte order is:",dt.byteorder)
print("Size is:",dt.itemsize)
print("Data type is:",dt.name)
Result:
5. ndarray.itemsize()
Program:
import numpy as geek
arr = geek.array([1, 2, 3, 4], dtype = geek.float64)
gfg = arr.itemsize
print (gfg)
Result:
Nikhil Nagesh Gosavi PRN No-191041025 Roll No-19
6. numpy.zeros()
Program:
import numpy as geek
c = geek.zeros([3, 3])
print("\nMatrix c : \n", c)
Result:
Nikhil Nagesh Gosavi PRN No-191041025 Roll No-19
7. numpy.ones()
Program:
import numpy as geek
c = geek.ones([3, 3])
print("\nMatrix c : \n", c)
Result:
Nikhil Nagesh Gosavi PRN No-191041025 Roll No-19
8. numpy.arange()
Program:
import numpy as geek
Result:
9. numpy.linspace()
Program:
import numpy as geek
print("B\n", geek.linspace(2.0, 3.0, num=5, retstep=True), "\n")
x = geek.linspace(0, 2, 10)
print("A\n", geek.sin(x))
Result: