What are the types of operators in python?
Answers
Python divides the operators in the following groups:
Arithmetic operators.
Assignment operators.
Comparison operators.
Logical operators.
Identity operators.
Membership operators.
Bitwise operators.
There are mainly 4 types of operators in Python.
- Arithmetic Operators
- Relational Operators
- Logical Operators
- Assignment Operators
1. Arithmetic operators
Arithmetic operators, as the name suggests, are operators that deal with calculations/algebraic expression. They include addition [+], subtraction [-], multiplication [*], division [/], exponentiation [**], modulo [%] and floor division [//].
2. Relational operators
Relational operators are used to compare two values that may result to either True or False. They include less than [<], greater than [>], less than/equal to [<=], greater than/equal to [>=], not equal to [!=] and equal to [=].
3. Logical operators
Logical operators are used to compare two expressions/values, somewhat similar to relational operators. They include and, or and not.
4. Assignment operators
Assignment operators are used to assign values into variables. They include =, +=, -=, /=, %=, **= and //=.