Operators in Python with Example for class 6 and 7 (Easy Guide)
In Python,Operator is a symbol or keyword that perform an operation on a one or more values called Operands to produce result. Operators are fundamental pillar of the python because they provide the power to manipulate the data, perform calculations and control logic for performing task according to real world. Python has several types of operators.
- Arithmetic Operators : Used to perform Mathematical Operations.
- Comparison or Relational Operators : Is used to compare value and return TRUE or FALSE
- Logical Operators :Is used to combine the statement
- Assignment Operators :Is used to assign the value.
🔢 Arithmetic Operators | ||
| Operator Name | Symbols | Example |
| Addition | + | A=10 A+2 print(A) Answer : 100 |
| Subtraction | - | A=10 A-2 print(A) Answer : 8 |
| Multiplication | * | A=10 A*2 print(A) Answer : 20 |
| Division | / | A=10 A/2 print(A) Answer : 5 |
| Floor Division | // | A=10 A/3 print(A) Answer : 3 |
| Modulus | % | A=10 A%3 print(A) Answer : 1 |
| Exponentiation | ** | A=10 A**2 print(A) Answer : 100 |
⚖️ Comparison or Relational Operators | ||
| Equal To | "==" | |
| Not equal To | "!=" | |
| Less Than | "<" | |
| Greater than | ">" | |
| Less than or Equal To | "<=" | |
| Greater than or Equal To | ">=" | 5>=5, Result True |
🔗 Logical Operators | ||
| AND | && | |
| OR | // | |
| NOT | // | |
📦 Assignment Operators | ||
| Assign the value | = | A=10 B=A print(B) Answer : 10 |
| Addition and assign | += | A=10 A+=3 print(A) Answer : 13 |
| Subtraction and assign | -= | A=10 A-=3 print(A) Answer : 7 |
| Multiplication and assign | *= | A=10 A*=3 print(A) Answer : 30 |
| Division and assign | /= | A=10 A/=2 print(A) Answer : 5 |
| Floor division and assign | //= | A=10 A//=3 print(A) Answer : 3 |
| Modulus and assign | %= | A=10 A%=3 print(A) Answer : 1 |
| Exponentiation and Assign | **= | A=10 A**=2 print(A) Answer : 100 |