1. Write a Python Numpy program to generate 3x3 matrix and display the maximum and minimum of y axis .
The output is:
Expected Answer:
3x3 matrix:
[[0 1 2]
[3 4 5]
[6 7 8]]
Maximum value along the y axis: [2 5 8]
Minimum value along the y axis: [0 3 6]
Sample Answer:
import numpy as np
a = np.arange(9).reshape((3, 3))
print("\n3x3 matrix:")
print(a)
print("\nMaximum value along the y axis:", np.amax(a, 1))
print("Minimum value along the y axis:", np.amin(a, 1))
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)