You are on page 1of 7

Nikhil Nagesh Gosavi PRN No-191041025 Roll No-19

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

b = geek.zeros(2, dtype = int)


print("Matrix b : \n", b)

a = geek.zeros([2, 2], dtype = int)


print("\nMatrix a : \n", a)

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

b = geek.ones(2, dtype = int)


print("Matrix b : \n", b)

a = geek.ones([2, 2], dtype = int)


print("\nMatrix a : \n", a)

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

print("A\n", geek.arange(4).reshape(2, 2), "\n")

print("A\n", geek.arange(4, 10), "\n")

print("A\n", geek.arange(4, 20, 3), "\n")

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:

You might also like