# Python Operator

Operators are the constructs which can manipulate the value of operands.

Consider the expression 4 + 5 = 9. Here, 4 and 5 are called operands and + is called operator.

## Types of Operator

Python language supports the following types of operators.

• Python Arithmetic Operators

Assume variable a holds 10 and variable b holds 20, then

• 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 Assignment Operators

Assume variable a holds 10 and variable b holds 20, then

• Python Bitwise Operators

Bitwise operator works on bits and performs bit by bit operation. Assume if a = 60; and b = 13; Now in binary format they will be as follows −

a = 0011 1100

b = 0000 1101

—————–

a&b = 0000 1100

a|b = 0011 1101

a^b = 0011 0001

~a  = 1100 0011

There are following Bitwise operators supported by Python language

• Python Logical Operators

There are following logical operators supported by Python language.

Assume variable a holds 10 and variable b holds 20, then

• 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 Identity Operators

Identity operators compare the memory locations of two objects. There are two Identity operators explained below:

## Related Posts

• 71
Example: #!/usr/bin/python a = 60 # 60 = 0011 1100 b = 13 # 13 = 0000 1101 c = 0 c = a & b; # 12 = 0000 1100 print "Line 1 - Value of c is ", c c = a | b; # 61 = 0011…
Tags: operators, python, operator
• 71
Example: !/usr/bin/python a = 21 b = 10 c = 0 c = a + b print "Line 1 - Value of c is ", c c += a print "Line 2 - Value of c is ", c c *= a print "Line 3 - Value of c is…
Tags: python, operator, operators
• 64
Welcome to the Python Knowledge Base and Tutorial   Python : Overview : What is Python? Why learn Python? Feature of Python Basic Syntax Where to write python program? Check if python already installed Python : Installation on Windows and Simple Example How to install python in windows? Simple Example…
Tags: python, operators
• 57
There are used to compare the memory locations of two operators. Example: #!/usr/bin/python a = 20 b = 20 if ( a is b ): print "Line 1 - a and b have same identity" else: print "Line 1 - a and b do not have same identity" if (…
Tags: python, operators, operator
• 57
These operators compare the values on either sides of them and decide the relation among them. They are also called Relational operators. Example: #!/usr/bin/python a = 21 b = 10 c = 0 if ( a == b ):    print "Line 1 - a is equal to b" else:…
Tags: python, operator, operators

#### Satya Prakash

VOIP Expert: More than 8 years of experience in Asterisk Development and Call Center operation Management. Unique Combination of Skill Set as IT, Analytics and operation management.

### One thought on “Python Operator”

• February 10, 2016 at 2:46 am