2. Write a Python Numpy program to generate 10 integers then change the integer type to float type.
The output is:
Array a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Expected Answer:
Initial array: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Converted to float type: [ 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.]
Sample Answer:
import numpy as np a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] print("Initial array:", a) b = np.asfarray(a) print("\nConverted to float type:", b)
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)