Course
Operators
Python Tutorial
This Python tutorial has been written for the beginners to help them understand the basic to advanced concepts of Python Programming Language. After completing this tutorial, you will find yourself at a great level of expertise in Python, from where you can take yourself to the next levels to become a world class Software Engineer.
Operators
What are Operators in Python?
Python and other programming languages provide different type of operators which are symbols (sometimes called keywords) and used to perform a certain most commonly required operations on one or more operands. Operators allow different operations like addition, subtraction, multiplication, division etc.
Types of Operators in Python
Python language supports the following types of operators
Arithmetic
Operators
Comparison
(Relational) Operators
Assignment
Operators
Logical
Operators
Bitwise
Operators
Membership
Operators
Identity
Operators
Let us have a look at all the operators one by one.
Python Arithmetic Operators
Arithmetic operators are used to perform basic mathematical operations. Assume variable a holds 10 and variable b holds 20, then
[ Python Arithmetic Operators ]
Python Comparison Operators
These operators compare the values on either sides of them and decide the relation among them. They are also called Relational operators.
Assume variable a holds 10 and variable b holds 20, then
[ Python Comparison Operators ]
Python Assignment Operators
Assignment operators are used to assign values to variables. Following is a table which shows all Python assignment operators.
[ Python Assignment Operators ]
Python Bitwise Operators
Bitwise operator works on bits and performs bit by bit operation. These operators are used to compare binary numbers.
There are following Bitwise operators supported by Python language
[ Python Bitwise Operators ]
Python Logical Operators
Python logical operators are used to combile two or more conditions and check the final result. There are following logical operators supported by Python language. Assume variable a holds 10 and variable b holds 20 then
[ Python Logical Operators ]
Python Membership Operators
Python's membership operators test for membership in a sequence, such as strings, lists, or tuples. There are two membership operators as explained below −
[ Python Membership Operators ]
Python Identity Operators
Identity operators compare the memory locations of two objects. There are two Identity operators explained below
[ Python Identity Operators ]
Python Operators Precedence
The following table lists all operators from highest precedence to lowest.
[ Show Example ]