3. Write a Python Numpy program to generate 3x3 array and calculate to find out the difference between maximum and minimum value in x axis.
The output is:
Expected Answer:
3x3 array:
[[0 1 2]
[3 4 5]
[6 7 8]]
Difference between the maximum and the minimum values of the 3x3 array:
[2 2 2]
Sample Answer:
import numpy as np a = np.arange(9).reshape((3, 3)) print("\n3x3 array:") print(a) r1 = np.ptp(a, 1) print("\nDifference between the maximum and the minimum values of the 3x3 array:") print(r1)
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)