Page 121 - ComputerGenius_V2.1_Class8
P. 121
Description:
In the above program, we assigned values to different variables and then performed different
arithmetic operations on it.
Example 7: Comparison operators in Python.
Program:
x = 10
y = 12
print('x>y=', x>y)
print('x<y=', x<y)
print('x==y=', x==y)
print('x!=y=', x!=y)
print('x>=y=', x>=y)
print('x<=y=', x<=y)
Output:
x > y = False
x < y = True
x == y = False
x != y = True
x >= y = False
x <=y = True
Description:
In the above program, we assigned values to different variables and then performed different
arithmetic operations on it.
Example 8: Logical Operators in Python.
Program:
x = True
y = False
print('x and y is', x and y)
print('x or y is', x or y)
print('not x is x', not x )
Output:
x and y is False
x or y is True
not x is False
Description:
In the above program, we have used two variables and then performed various logical operations on
it. Compared variable values logically.
Basics of Python 119

