Write a NumPy program to test a given array element-wise for finiteness (not infinity or not a Number)

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

Write a NumPy program to test a given array element-wise for finiteness (not infinity or not a Number).

الأجوبة

import numpy as np
a = np.array([1, 0, np.nan, np.inf])
print("Original array")
print(a)
print("Test a given array element-wise for finiteness :")
print(np.isfinite(a))

Sample Output:

Original array
[  1.   0.  nan  inf]
Test a given array element-wise for finiteness :
[ True  True False False]
هل كان المحتوى مفيد؟

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

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