Write a NumPy program to calculate the arithmetic means of corresponding elements of two given arrays of same size

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

Write a NumPy program to calculate the arithmetic means of corresponding elements of two given arrays of same size.

الأجوبة

import numpy as np 
nums1 = np.array([[2, 5, 2],
              [1, 5, 5]])
nums2 = np.array([[5, 3, 4],
              [3, 2, 5]])
print("Array1:") 
print(nums1)
print("Array2:") 
print(nums2)
print("\nArithmetic means of corresponding elements of said two arrays:")
print(np.divide(np.add(nums1, nums2), 2))

Sample Output:

Array1:
[[2 5 2]
 [1 5 5]]
Array2:
[[5 3 4]
 [3 2 5]]

Arithmetic means of corresponding elements of said two arrays:
[[3.5 4.  3. ]
 [2.  3.5 5. ]]
هل كان المحتوى مفيد؟

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

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