Write a NumPy program to get the minimum and maximum value of a given array along the second axis

  • برمجة بايثون

Write a NumPy program to get the minimum and maximum value of a given array along the second axis.

الأجوبة

import numpy as np
x = np.arange(4).reshape((2, 2))
print("\nOriginal array:")
print(x)
print("\nMaximum value along the second axis:")
print(np.amax(x, 1))
print("Minimum value along the second axis:")
print(np.amin(x, 1))

Sample Output:

Original array:
[[0 1]
 [2 3]]

Maximum value along the second axis:
[1 3]
Minimum value along the second axis:
[0 2]
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...