Write a NumPy program to create an element-wise comparison (greater, greater_equal, less and less_equal) of two given arrays
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]
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer