Download our e-book of Introduction To Python
Pallavi Dhotre
2 years ago
x=10
y=5
# Addition
print("Addition:",x+y)
# Subtraction
print('Subtraction:',x-y)
# Multiplication
print('Multiplication:',x*y)
# Division
print('Division:',x/y)
# Division in python, Quotient after integer (whole number) division
print("Floor division",x//y)
# Remainder after integer (whole number) division; also called modulo operator python
print('Modulo:',x%y)
# Exponentiation or power (x power of y)
print("Exponential:",x**y)
Addition: 15
Subtraction: 5
Multiplication: 50
Division: 2.0
Floor division 2
Modulo: 0
Exponential: 100000
x=20
y=4
x += y # Addition also equivalent to x = x + y
print(x)
x -= y # Subtraction also equivalent to x = x - y
print(x)
x *= y # Multiplication also equivalent to x = x * y
print(x)
x /= y # Division also equivalent to x = x / y
print(x)
x //= y # Floor Division also equivalent to x = x // y
print(x)
x %= y # Modulus also equivalent to x = x % y
print(x)
x **= y # Exponentiation also equivalent to x = x ** y
print(x)
24
20
80
20.0
5.0
1.0
1.0
x=20
y=4
print('Greater than',x>y)
print('Less than',x<y)
print('Greater than equals to',x>=y)
print('Less than equals to',x<=y)
print('Equals to ',x==y)
print('Not equals to',x!=y)
Greater than True
Less than False
Greater than equals to True
Less than equals to False
Equals to False
Not equals to True
a=10
b=a+2
print((a>5) and (b>a)) #and operator
print((a>15) or (b>a)) #or operator
print(a!=b) #not operator
True
True
True
x=10y=xprint(x is y)print(x is not y)
True
False
x=[1,2,3,4,5]print(1 in x)print(2 not in x)
True
False