- Different Methodologies in Project Management
- Difference between Soap and Rest | Know more about it
- What is Python array? Learn with examples
- Best Career options after Engineering | Everything You Need to Know [OverView]
- What is list in Python ? All you need to know [ OverView ]
- What is Data Modelling? : All you need to know [ OverView ]
- What are Microservices? : A Complete Guide For Beginners with Best Practices
- What is Python Programming | A Definitive Guide with Best Practices
- All You Need To Know About Python List | A Complete Guide For Beginners with Best Practices
- What Is a Software Developer | Software Developer job description and duties | Everything You Need to Know
- What is Artificial Intelligence Chatbot?
- Kotlin vs Java | Know Their Differences and Which Should You Learn?
- What is Abstraction in Java | Implementations of Abstraction in Java | A Definitive Guide with Best Practices
- What are the Important Data Structures and Algorithms in Python?
- Go vs Python | Know Their Differences and Which Should You Learn?
- Best Python IDEs and Code Editors | Expert’s Top Picks | Everything You Need to Know
- Go Programming Language | Expert’s Top Picks | A Definitive Guide [ OverView ]
- Python Scopes and Their Built-in Functions | Everything You Need to Know | Expert’s Top Picks
- Python String Formatting | A Complete Guide For Beginners [ OverView ]
- Python Serialization | A Complete Guide For Beginners | Learning Guide
- What is .Net FrameWork? Uses and its Benefits | Everything You Need to Know
- What is Quality Assurance ? : A Definitive Guide | Everything You Need to Know [ OverView ]
- What is Spike Testing ? : A Definitive Guide | Expert’s Top Picks | Free Guide Tutorial
- Average Full Stack Developer Salary in India [ For Freshers and Experience ]
- What is WSDL in Web Services ? Expert’s Top Picks | Free Guide Tutorial
- Virtual Instrumentation using Labview | Comprehensive Guide [ Explained ]
- Gradle vs Maven | Know Their Differences and Which Should You Learn?
- Python Sleep Method | Free Guide Tutorial & REAL-TIME Examples
- Kotlin vs Python | A Complete Guide with Best Practices
- Spring Boot vs Spring MVC | Differences and Which Should You Learn?
- IT Engineer Salary in India – How much does one earn?
- What is pip ? and Getting Started with Python pip | All you need to know [ OverView ]
- Node.js Installation on Windows and Ubuntu | Free Guide Tutorial
- Skills Needed for Full Stack Developers | All you need to know [ OverView ]
- What is Axios in React? and Its Uses [ OverView ]
- What is MEAN Stack? All you need to know [ OverView ]
- How to Install Node.JS on Ubuntu | Everything You Need to Know
- Average Annual Salary of a Python Certified Professional – Career Path
- What is Scala Programming? A Complete Guide with Best Practices
- What Is User Input in Python? Expert’s Top Picks
- Interface vs Abstract Class | Difference You Should Know
- Final Year Computer Science Project Ideas | All you need to know [ OverView ]
- Technical Architect | Free Guide Tutorial & REAL-TIME Examples
- Logical Programs in Java | Step-By-Step Process
- C++ vs Java | Difference You Should Know
- What is C Programming? Comprehensive Guide
- What Is a Quality Engineer? ( Everything You Need to Know )
- Python Project Ideas for Beginners | All you need to know
- How to Run Python Scripts? Comprehensive Guide
- Python Operators
- How To Install NumPy in Python?
- Top Software Courses to Get High Paying Jobs
- Loops In Python
- Tips to Avoid Application Rejection
- Top Young App Developers Who Became Millionaires
- Top Technical Courses After Graduation
- Node JS Architecture
- What is PyCharm?
- Resources To Help You Learn Java Programming
- How to Become a Software Engineer?
- Best Programming Languages to Learn in 2020
- Scala vs Python
- How to Become a Full Stack Developer?
- The Most Popular Java Applications Used World-wide
- What is Java String?
- Full Stack Developer vs Front End Developer vs Back End Developer
- Python Collections
- Identifiers in Python
- Dynamic Method Dispatch in Java
- Hadoop Ecosystem
- Method Overloading in Python
- Convert Decimal To Binary In Python
- How To Make A Chatbot In Python?
- How to Input a List in Python?
- Hash Tables and Hashmaps in Python
- Top Python Framework’s
- Python Split Method with Example
- Python Enumerate
- Inheritance in Java
- Init in Python
- Goto Statement in Python
- Literals in Java
- Polymorphism in Oops
- Socket Programming in Python
- Object Class in Java
- Break, Continue, and Pass Statements in Python
- Exception Handling in Java
- Java BASIC Programs
- Different Methodologies in Project Management
- Difference between Soap and Rest | Know more about it
- What is Python array? Learn with examples
- Best Career options after Engineering | Everything You Need to Know [OverView]
- What is list in Python ? All you need to know [ OverView ]
- What is Data Modelling? : All you need to know [ OverView ]
- What are Microservices? : A Complete Guide For Beginners with Best Practices
- What is Python Programming | A Definitive Guide with Best Practices
- All You Need To Know About Python List | A Complete Guide For Beginners with Best Practices
- What Is a Software Developer | Software Developer job description and duties | Everything You Need to Know
- What is Artificial Intelligence Chatbot?
- Kotlin vs Java | Know Their Differences and Which Should You Learn?
- What is Abstraction in Java | Implementations of Abstraction in Java | A Definitive Guide with Best Practices
- What are the Important Data Structures and Algorithms in Python?
- Go vs Python | Know Their Differences and Which Should You Learn?
- Best Python IDEs and Code Editors | Expert’s Top Picks | Everything You Need to Know
- Go Programming Language | Expert’s Top Picks | A Definitive Guide [ OverView ]
- Python Scopes and Their Built-in Functions | Everything You Need to Know | Expert’s Top Picks
- Python String Formatting | A Complete Guide For Beginners [ OverView ]
- Python Serialization | A Complete Guide For Beginners | Learning Guide
- What is .Net FrameWork? Uses and its Benefits | Everything You Need to Know
- What is Quality Assurance ? : A Definitive Guide | Everything You Need to Know [ OverView ]
- What is Spike Testing ? : A Definitive Guide | Expert’s Top Picks | Free Guide Tutorial
- Average Full Stack Developer Salary in India [ For Freshers and Experience ]
- What is WSDL in Web Services ? Expert’s Top Picks | Free Guide Tutorial
- Virtual Instrumentation using Labview | Comprehensive Guide [ Explained ]
- Gradle vs Maven | Know Their Differences and Which Should You Learn?
- Python Sleep Method | Free Guide Tutorial & REAL-TIME Examples
- Kotlin vs Python | A Complete Guide with Best Practices
- Spring Boot vs Spring MVC | Differences and Which Should You Learn?
- IT Engineer Salary in India – How much does one earn?
- What is pip ? and Getting Started with Python pip | All you need to know [ OverView ]
- Node.js Installation on Windows and Ubuntu | Free Guide Tutorial
- Skills Needed for Full Stack Developers | All you need to know [ OverView ]
- What is Axios in React? and Its Uses [ OverView ]
- What is MEAN Stack? All you need to know [ OverView ]
- How to Install Node.JS on Ubuntu | Everything You Need to Know
- Average Annual Salary of a Python Certified Professional – Career Path
- What is Scala Programming? A Complete Guide with Best Practices
- What Is User Input in Python? Expert’s Top Picks
- Interface vs Abstract Class | Difference You Should Know
- Final Year Computer Science Project Ideas | All you need to know [ OverView ]
- Technical Architect | Free Guide Tutorial & REAL-TIME Examples
- Logical Programs in Java | Step-By-Step Process
- C++ vs Java | Difference You Should Know
- What is C Programming? Comprehensive Guide
- What Is a Quality Engineer? ( Everything You Need to Know )
- Python Project Ideas for Beginners | All you need to know
- How to Run Python Scripts? Comprehensive Guide
- Python Operators
- How To Install NumPy in Python?
- Top Software Courses to Get High Paying Jobs
- Loops In Python
- Tips to Avoid Application Rejection
- Top Young App Developers Who Became Millionaires
- Top Technical Courses After Graduation
- Node JS Architecture
- What is PyCharm?
- Resources To Help You Learn Java Programming
- How to Become a Software Engineer?
- Best Programming Languages to Learn in 2020
- Scala vs Python
- How to Become a Full Stack Developer?
- The Most Popular Java Applications Used World-wide
- What is Java String?
- Full Stack Developer vs Front End Developer vs Back End Developer
- Python Collections
- Identifiers in Python
- Dynamic Method Dispatch in Java
- Hadoop Ecosystem
- Method Overloading in Python
- Convert Decimal To Binary In Python
- How To Make A Chatbot In Python?
- How to Input a List in Python?
- Hash Tables and Hashmaps in Python
- Top Python Framework’s
- Python Split Method with Example
- Python Enumerate
- Inheritance in Java
- Init in Python
- Goto Statement in Python
- Literals in Java
- Polymorphism in Oops
- Socket Programming in Python
- Object Class in Java
- Break, Continue, and Pass Statements in Python
- Exception Handling in Java
- Java BASIC Programs
Python Operators
Last updated on 14th Oct 2020, Artciles, Blog, Software Engineering
Python Operators
Operators are used to perform operations on variables and values.
Python divides the operators in the following groups:
- Arithmetic operators
- Assignment operators
- Comparison operators
- Logical operators
- Identity operators
- Membership operators
- Bitwise operators
Subscribe For Free Demo
Error: Contact form not found.
1) Arithmetic Operators
Python programming language supports different kinds of arithmetic operators for both integer and floating point like addition, subtraction, multiplication, division and so on.
| Operator Type | Definition |
|---|---|
| Addition (+) | Addition operator |
| Subtraction (-) | Subtraction operator |
| Multiplication (*) | Multiplication operator |
| Division (/) | Division operator |
| Modulus (%) | Reminder operator |
| Floor division (//) | Divides and returns the value of the remainder. |
| Exponentiation (**) | Raises the left operand to the power of right. |
Example:
- x = 15y = 10print(‘x + y =’, x+y)
Output: x + y = 25
- print(‘x – y =’, x-y)
Output: x – y = 5
- print(‘x * y =’, x*y)
Output: x * y = 150
- print(‘x / y =’, x/y)
Output: x / y = 1.5
- print(‘x % y =’, x%y)
Output: x % y = 5
- print(‘x // y =’, x//y)
Output: x // y = 1
- print(‘x ** y =’, x**y)
Output: x ** y = 576650390625

2) Comparison Operators
Comparison operators are used for comparing values. It either returns True or False according to the condition.
| Operators | Definition |
|---|---|
| Greater than (>) | True if left operand is greater than the right |
| Less than (<) | True if left operand is less than the right |
| Equal to (==) | True if both operands are equal |
| Not equal to (!=) | True if operands are not equal |
| Greater than or equal to (>=) | True if left operand is greater than or equal to the right |
| Less than or equal to (<=) | True if left operand is less than or equal to the right |
Example:
- x = 8y = 15(‘x>y is’,x>y)
Output: x > y is False
- print(‘x< y is’, x<y)
Output: x < y is True
- print(‘x == y is’, x==y)
Output: x == y is False
- print(‘x != y is’, x!=y)
Output: x != y is True
- print(‘x >= y is’, x>=y)
Output: x >= y is False
- print(‘x<= y is’, x<=y)
Output: x <= y is True

3) Logical Operators
Logical operators are used for performing AND, OR and NOT operations. It either returns True or False according to the condition.
| Operators | Definitions |
|---|---|
| and | True if both the operands are true |
| or | True if either of the operands is true |
| not | True if operand is false |
Example:
- a = Trueb = Falseprint(‘a and b is’, a and b)
Output: a and b is False
- print(‘a or b is’, a or b)
Output: a or b is True
- print(‘not a is’, not a)
Output: not a is False

4) Bitwise Operators
Bitwise operators operate on bits and perform bit by bit operation.
| Operators | Definitions |
|---|---|
| & | Bitwise AND |
| | | Bitwise OR |
| ~ | Bitwise NOT |
| ^ | Bitwise XOR |
| >> | Bitwise right shift |
| << | Bitwise left shift |
5) Assignment Operator
An assignment operator is used to assign a value to a variable.
| Operators | Definitions | Output |
|---|---|---|
| = | x = 15 | x = 15 |
| += | x += 15 | x = x + 15 |
| -= | x -= 15 | x = x – 15 |
| *= | x *= 15 | x = x * 15 |
| /= | x /= 15 | x = x / 15 |
| %= | x %= 15 | x = x % 15 |
| //= | x //= 15 | x = x // 15 |
| **= | x **= 15 | x = x ** 15 |
| &= | x &= 15 | x = x & 15 |
| |= | x |= 15 | x = x | 15 |
| ^= | x ^= 15 | x = x ^ 15 |
| >>= | x >>= 15 | x = x >> 15 |
| <<= | x <<= 15 | x = x << 15 |
6) Identity Operators
Python offers 2 types of identity operators i.e is and is not.
Both are used to compare if two values are located on the same part of the memory. Two variables that are equal does not imply that they are identical.
| Operators | Definitions |
|---|---|
| is | True if the operands are identical |
| is not | True if the operands are not identical |
Example:
- a1 = 3b1 = 3a2 = “Python”b2 = “Python” a3 = [4,5,6]b3 = [4,5,6] print(a1 is not b1)
Output: False
- print(a2 is b2)
Output: True
- print(a3 is b3)
Output: False

Here a3 and b3 are listed, interpreter allocates memory separately and even though they are equal, it returns False.
7) Membership Operators
Python offers 2 types of membership operators i.e in and not in.
Both are used to test whether a value or variable is in a sequence.
| Operators | Definitions |
|---|---|
| in | True if value is found in the sequence |
| not in | True if value is not found in the sequence |
Example:
- a = “Python operators”b = {1:’x’,2:’y’} print(“P” in a)
Output: True
- print(“python” not in a)
Output: False
- print(1 in b)
Output: True
- print(‘y’ in b)
Output: False

1 is key and ‘x’ is the value in dictionary b. Hence, ‘y’ in b returns False.
Hope you are clear about Python operators and their various types.
