6. Write a Python Numpy program to generate a numpy array in range of 1 to 10 therefore reverse the array.
The output is:
a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Expected Answer:
Original array:
[ 1 2 3 4 5 6 7 8 9 10]
Reverse array:
[10 9 8 7 6 5 4 3 2 1]
Sample Answer:
import numpy as np a = np.arange(1, 11) print("Original array:") print(a) b = a[::-1] print("\nReverse array:") print(b)
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)