xxxxxxxxxx
'GE' in VINIX
>>> False
'GOOGL' in VINIX
>>> True
xxxxxxxxxx
# Below follow the comparison operators that can be used in python
# == Equal to
42 == 42 # Output: True
# != Not equal to
'dog' != 'cat' # Output: True
# < Less than
45 < 42 # Output: False
# > Greater Than
45 > 42 # Output: True
# <= Less than or Equal to
40 <= 40 # Output: True
# >= Greater than or Equal to
39 >= 40 # Output: False
xxxxxxxxxx
# Let's learn the comparison operators in Python
x = 5
# Equal to
if x == 5:
print('X is equal to 5')
# Greater than
if x > 4:
print('X is greater than 4')
# Greater than or equal to
if x >= 5:
print('X is greater than or equal to 5')
# Less than
if x < 6:
print('X is less than 6')
# Less than or equal to
if x <= 6:
print('X is less than or equal to 6')
# Not equal
if x != 6:
print('X is not equal to 6')
xxxxxxxxxx
# Comparison is done through "lexicographic" order of letters
# Change the variable 'word' then run and see the results
# Remember a capital letter comes before a simple letter
word = 'banana'
if word == 'banana':
print('All right, bananas.')
if word < 'banana':
print('Your word', word, 'comes before banana')
elif word > 'banana':
print('Your word', word, 'comes after banana')
else:
print('All right, bananas.')
xxxxxxxxxx
# Examples of Relational Operators
a = 13
b = 33
# a > b is False
print(a > b)
# a < b is True
print(a < b)
# a == b is False
print(a == b)
# a != b is True
print(a != b)
# a >= b is False
print(a >= b)
# a <= b is True
print(a <= b)
xxxxxxxxxx
number_of_seats = 30
numbre_of_guests = 25
if numbre_of_guests <= number_of_seats:
print("it's ok")
else:
print("it's not ok")