Comparison operator

20 August 2020

Code

Equal

# Equal
x = (2 == 3)
y = np.equal(2, 3)

print("x =", x)
print("y =", y)
x = False
y = False

.

Not equal

# Not Equal
x = (2 != 3)
y = np.not_equal(2, 3)

print("x =", x)
print("y =", y)
x = True
y = True

.

Array Equal

# Array Equal
a = np.array([[1,2],[3,4]]) 
b = np.array([[1,2],[3,4]]) 

x = (a == b)
y = np.array_equal(a, b) # True if both arrays have same 'shape' and 'elements'
z = np.array_equiv(a, b) # True if both arrays are 'shape consistent' and have 'same elements'

print("x =", x)
print("y =", y)
print("z =", z)
x = [[ True  True]
 [ True  True]]
y = True
z = True

.

Greater

# Greater
x = (4 > 3)
y = np.greater(4, 3)

print("x =", x)
print("y =", y)
x = True
y = True

.

Greater Equal

# Greater Equal
x = (3 >= 3)
y = np.greater_equal(3, 3)

print("x =", x)
print("y =", y)
x = True
y = True

.

Less

# Less
x = (2 < 3)
y = np.less(2, 3)

print("x =", x)
print("y =", y)
x = True
y = True

.

Less equal

# Less equal
x = (2 <= 3)
y = np.less_equal(2, 3)

print("x =", x)
print("y =", y)
x = True
y = True






Any errors in code above?
Please send a message.