DS31032023 - NumPy Practice

Hello Learners,

NumPy for additional practice

Q1. Write a NumPy program to print the NumPy version on your system.

Q2. Write a NumPy program to convert a list of numeric values into a one-dimensional NumPy array.
Expected Output:
Original List: [12.23, 13.32, 100, 36.32]
One-dimensional NumPy array: array([ 12.23 13.32 100. 36.32])

Q3. Write a NumPy program to convert an array to a floating type.
Sample output:
Original array
[1, 2, 3, 4]
Array converted to a float type:
[ 1. 2. 3. 4.]

Q4. Write a NumPy program to create a null vector of size 10 and update the sixth value to 11.
[ 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
Update sixth value to 11
[ 0. 0. 0. 0. 0. 0. 11. 0. 0. 0.]

Q5. Write a NumPy program to create an array with values ranging from 12 to 38.
Expected Output:
[12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37]

2 Likes

Answers Of NumPy Practice
1.
import numpy as np
print(np.version)

import numpy as np
list1 = [12.23, 13.32, 100, 36.32]
print(“Original List:”, list1)
arr = np.array(list1)
print("One-D NumPy array: ",arr)

import numpy as np
arr = [1, 2, 3, 4]
print(“Original array”)
print(arr)
i = np.asfarray(arr)
print("Array converted to a float type : ")
print(i)

import numpy as np
a = np.zeros(10)
print(a)
print(“Update sixth value to 11”)
a[6] = 11
print(a)

import numpy as np
a = np.arange(12, 38)
print(a)

why it is showing version

double underscore is not displaying