3. Write a Python Numpy program to input a list of number then generate one dimensional numpy array as output.
The output is:
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Expected Answer:
a: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Class of a is [class 'list']
b: [ 1 2 3 4 5 6 7 8 9 10]
Class of b is [class 'numpy.ndarray']
Sample Answer:
import numpy as np a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] print("a:", a) print("Class of a is", type(a)) b = np.array(list_a) print("\nb: ", b) print("Class of b is", type(b))
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)