LESSON 5:
Basic Operators
Operators are the special symbols that can manipulate the value of
operands.
Python language supports the following types of operators.
• Arithmetic Operators
• Comparison or Relational Operators
• Assignment Operators
• Bitwise Operators
• Logical Operators
• Membership Operators
• Identity Operators
Arithmetic Operators
Arithmetic Operators are used to perform arithmetic operations.
Below table shows the arithmetic operators and examples.
Comparison or Relational Operators
As the name suggests the comparison or relational operators are
useful to compare values.
Below table shows the comparison and relational operators with
examples.
Assignment Operators
Assignment operators are used for assigning values to variables.
Bitwise Operators
Bitwise operators enable us to directly operate or manipulate bits.
Because everything in a computer is represented by bits, that is, a
series of 0’s (zero) and 1’s (one). One of the key usages of bitwise
operators is for parsing hexadecimal colors
Logical Operators
These are useful to check two variables against given condition and
the result will be True or False appropriately.
Membership Operators
Membership operators are useful to test if a value is found in a
sequence, that is, string,
list, tuple, set, or dictionary. There are two membership operators in
Python, ‘in’ and
‘not in.
Identity Operators
Identity operators are useful to test if two variables are present on the
same part of the
memory. There are two identity operators in Python, ‘is’ and ‘is not’.