Operators are used to perform operations on values and variables.
Types of Operators in Python:
- Arithmetic operators
- Logical operators
- Comparision operators
Arithmetic operators:
Arithmetic operators are used to perform operations like addition, subtraction, multiplication and division.
Ex:
a = 10
b = 5
print("Addition:", a + b)
print("Subtraction:", a - b)
print("Multiplication:", a * b)
print("Division:", a / b)
print("Floor Division:", a // b)
print("Modulus:", a % b)
print("Power:", a ** b)
Comparison operators:
Comparision operator is used to compare the values.
It returns boolean values
Ex:
a = 10
b = 20
print(a > b)
print(a < b)
print(a == b)
print(a != b)
print(a >= b)
print(a <= b)
Logical operators:
Logical operators performs AND, OR operations.
It is used to combined statements
Ex:
a=10
b=5
print(a>5 and a>7)
print(b<6 or a<9)
Top comments (1)
Good Start! Make sure to add references in blog. Write elaboratively!