4-Operators-1 6755317cd302c
4-Operators-1 6755317cd302c
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.
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.
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