Import As: - Version

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

1Q. Import numpy as `np` and print the version number.

Ans.

import numpy as np
print(np.__version__)

2. Q. Create a 1D array of numbers from 0 to 9.


Ans.
import numpy as np
print(np.arange(10))

3. Q. Create a 3×3 numpy array of all True’s.


Ans.
import numpy as np
a=np.full([3,4],'True', dtype=None)
print(a)

OR

import numpy as np
a=np.ones([3,4], dtype=bool)
print(a)

OR

import numpy as np
a=np.full([3,4], 'Boro', dtype=None)
print(a)

4. Q. Extract all odd numbers from arr.


Ans.
import numpy as np
arr = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
print(arr[arr % 2 == 1])

5. Q. Replace all odd numbers in  arr  with -1


Ans.

You might also like