You are on page 1of 11

COMPUTING APPLICATIONS WITH

PYTHON

UNIT – II
Operators and expressions
Operators:
The operator can be defined as a symbol which is responsible for a particular operation between two
operands. Operators are the pillars of a program on which the logic is built in a specific programming
language. Python provides a variety of operators, which are described as follows.

• Arithmetic operators

• Comparison operators

• Assignment Operators

• Logical Operators

• Bitwise Operators

• Membership Operators

• Identity Operators
1. Arithmetic Operators:

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


2. Comparison Operators:
3. Assignment Operators:
4. Bitwise Operators:

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

1. Compliment operator
2. And (&)
3. Or (|)
4. Xor (^)
5. Logical Operators:
6. Membership Operators:

In addition to the operators discussed previously, Python has membership operators, which test for
membership in a sequence, such as string s, lists, or tuples. There are two membership operators explained
below:
7. Identity Operators:

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

You might also like