Q:

Write a NumPy program compare two given arrays

0

Write a NumPy program compare two given arrays

All Answers

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

import numpy as np
a = np.array([1, 2])
b = np.array([4, 5])
print("Array a: ",a)
print("Array b: ",b)
print("a > b")
print(np.greater(a, b))
print("a >= b")
print(np.greater_equal(a, b))
print("a < b")
print(np.less(a, b))
print("a <= b")
print(np.less_equal(a, b))

Sample Output:

Array a:  [1 2]                                                        
Array b:  [4 5]                                                        
a > b                                                                  
[False False]                                                          
a >= b                                                                 
[False False]                                                          
a < b                                                                  
[ True  True]                                                          
a <= b                                                                 
[ 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