Professional Documents
Culture Documents
Lecture 5
Lecture 5
Sherina Sally
OUTLINE
• Arithmetic Operators
• Assignment Operators
• Comparison Operators
All Rights Reserved
• Logical Operators
• Identity Operators
• Membership Operators
• Bitwise Operators
1
ARITHMETIC OPERATORS
• Performs mathematical operations on numerical values
+ Addition a+b
- Subtraction a-b
ASSIGNMENT OPERATORS
• Assigns a literal to a variable
-= a -= 10 a = a - 10
*= a *= 10 a = a * 10
/= a /= 10 a = a / 10
%= a %= 10 a = a % 10
** = a**= 2 a = a ** 2
//= a //= 10 a = a // 10
2
COMPARISON OPERATORS
• Compares the values of two operands
LOGICAL OPERATORS
• Combines conditional statements
and (a <10) and (b<15) Returns True if both the conditions are True
3
IDENTITY OPERATORS
• Compares two objects by memory location
MEMBERSHIP OPERATORS
• Test for a value in a sequence: string, list, tuples
4
BITWISE OPERATORS
• Compares bits (1 and 0)
5
EVALUATING EXPRESSIONS
-(-3)
25
4