4. Write a Python Numpy program to generate 4x3 array and find out the median of the array.
The output is:
Expected Answer:
Initial 3x4 array:
[[ 0 1 2 3]
[ 4 5 6 7]
[ 8 9 10 11]]
Median of 3x4 array: 5.5
Sample Answer:
import numpy as np a = np.arange(12).reshape((3, 4)) print("Initial 3x4 array:") print(a) r1 = np.median(a) print("\nMedian of 3x4 array:", r1)
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)