Operators in Python
- An operator is a symbol used to perform mathematical or logical operations on values.
- The values on which an operator works are called operands.
- For example, in 10 + num, 10 and num are operands and + is an operator.
Types of Operators
- Arithmetic operator
- Relational operator
- Assignment operator
- Logical operator
- Identity operator
- Membership operator
Arithmetic Operators

Relational Operators

Logical Operator

Assignment Operator

Membership Operator

Identity Operators

Operator Precedence

- In a mathematical or logical expression, operator precedence decides which operator will be executed first.
- Operators with higher precedence are evaluated before operators with lower precedence.
- It helps Python to perform calculations in the correct order.
- The following table shows the precedence of different operators.
- Parenthesis can be used to override the precedence of operators. The expression within () is evaluated first.
- For operators with equal precedence, the expression is evaluated from left to right.
Do it by yourself
- Write a program to find average of five numbers
- Write a program to find cube of a given number.
- Write a program to convert oC to oF
- Write a program to swap values of two variables


