NUMPY BASIC EXERCISE 10
Create a program to show the greater, greater_equal, less and less equal comparison of the elements of two arrays
In this exercise, we are going to show comparison between elements of two arrays.
Code
import numpy as np arr1 = np.array([10,15]) arr2 = np.array([15, 20]) print("Original Arrays:") print(arr1) print(arr2) print("Greater Than Between arr1 and arr2") print(np.greater(arr1, arr2)) print("Greater Than or Equal to Between arr1 and arr2") print(np.greater_equal(arr1, arr2)) print("Less Than Between arr1 and arr2") print(np.less(arr1, arr2)) print("Less Than Or Equal to Between arr1 and arr2") print(np.less_equal(arr1, arr2))
Output
import numpy as np
arr1 = np.array([10,15])
arr2 = np.array([15, 20])
print("Original Arrays:")
print(arr1)
print(arr2)
print("Greater Than Between arr1 and arr2")
print(np.greater(arr1, arr2))
print("Greater Than or Equal to Between arr1 and arr2")
print(np.greater_equal(arr1, arr2))
print("Less Than Between arr1 and arr2")
print(np.less(arr1, arr2))
print("Less Than Or Equal to Between arr1 and arr2")
print(np.less_equal(arr1, arr2))