Q:

Write a NumPy program to create an element-wise comparison (greater, greater_equal, less and less_equal) of two given arrays

0

Write a NumPy program to create an element-wise comparison (greater, greater_equal, less and less_equal) of 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
x = np.array([3, 5])
y = np.array([2, 5])
print("Original numbers:")
print(x)
print(y)
print("Comparison - greater")
print(np.greater(x, y))
print("Comparison - greater_equal")
print(np.greater_equal(x, y))
print("Comparison - less")
print(np.less(x, y))
print("Comparison - less_equal")
print(np.less_equal(x, y))

Sample Output:

Original numbers:
[3 5]
[2 5]
Comparison - greater
[ True False]
Comparison - greater_equal
[ True  True]
Comparison - less
[False False]
Comparison - less_equal
[False  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