0% found this document useful (0 votes)
5 views23 pages

4-Operators-1 6755317cd302c

The document explains various types of operators in Python, including arithmetic, assignment, comparison, logical, bitwise, membership, and identity operators. It provides definitions and examples of each operator type, along with an exercise for evaluation. Additionally, it touches on operator precedence and concludes with a summary of the lesson content.

Uploaded by

sesadiperera16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views23 pages

4-Operators-1 6755317cd302c

The document explains various types of operators in Python, including arithmetic, assignment, comparison, logical, bitwise, membership, and identity operators. It provides definitions and examples of each operator type, along with an exercise for evaluation. Additionally, it touches on operator precedence and concludes with a summary of the lesson content.

Uploaded by

sesadiperera16
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Programming Techniques

Using Python
6.4 Python Operators
Operator and Operand?
§ Operators are used to perform operations on variables and values.
In other words, operators are constructs that can manipulate values
of operands.

§ Operands are the data items.

6+8
§ In the example above, 6 and 8 are considered operands while the + is
the operator.
Arithmetic
Arithmetic Operators are used with numeric values to
perform common mathematical operations like like addition, subtraction,
multiplication and division.
Assignment Operators are used to assign values to variables.
Comparison
Comparison Operators are used to compare values.
It returns either TRUE or FALSE according to the condition.
Logical
Logical Operators are used to combine conditional statements.
Logical operators in Python are AND, OR and NOT. Return TRUE or
FALSE as the output.
Bitwise
Bitwise Operators are used to compare integers.
The integers are first converted to binary and then operations are performed
on bit by bit. The result is of a decimal format.
Membership
Membership Operators are used to test if a value or variable is
present in a sequence such as lists, strings or tuples.

in: returns true if a sequence with the specified value is present in the object.
not in: returns true if a sequence with the specified value is not present in the
object
Identity
Identity Operators are used to compare the memory location of two
objects.
is: returns true if two variables point the same object.

is not: It returns false if two variables point the same object.


Python Operators – Exercise 1
Evaluate the following.

1) 16*20+4
2) 102-41//6
3) 20.0*12.0-4
4) 9.2*54**4
5) 9%5
6) 2**12+4+23-7%8
7) 124//8*6+234
8) 5**6+9-12
Operator Precedence
Lesson Summary

Operator and Operand


Types of Operators
Operator Precedence
Any
Questions ?
Thank You!
Yasiri Ranasinghe
BSc(Hons) Computing – Coventry University, UK
[email protected]

You might also like