Q:

Write a NumPy program to test whether any array element along a given axis evaluates to True

0

Write a NumPy program to test whether any array element along a given axis evaluates to True.
Note: 0 evaluates to False in python.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
print(np.any([[False,False],[False,False]]))
print(np.any([[True,True],[True,True]]))
print(np.any([10, 20, 0, -50]))
print(np.any([10, 20, -50]))

Sample Output:

False                                                                  
True                                                                   
True                                                                   
True

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now