Python Operators Notes-3
Python Operators Notes-3
NOTES
➢ Learning Objective
1. Use different operators in Python Programs.
2. Describe the function of different types of operators
1. Arithmetic Operators
• Operators that are used to perform mathematical/string operations
Operator Name Examples
+ Addition (number) / 100+25 “Indian” + “ ” + “School”
Concatenation (Strings) 125 Indian School
- Subtraction 100-25
75
* Multiplication(number) / 100*25 ‘ADIS’*3
Replication (Strings) 2500 ADISADISADIS
/ Division 8/5
1.6
// Floor Division (Integer 8//5
Division) 1
% Modulus (Reminder) 8%5
3
** Exponentiation 8**3
512
2. Assignment Operators
• Operators that are used to assign value to variables.
Operator Name Examples Explanation Value of x after
(if x=5) the operation
= Assignment x=5 x gets the value 5 5
4. Logical Operators
• Logical operators are used to combine or manipulate Boolean values (True or False).
• Return either ‘True’ or ‘False’ according to the condition.
Operator Description Examples Output
(Name) (x=2)
and Returns True if both True and True = True x<5 and x>1 True
operands are True. True and False = False x>1 and x!=2 False
False and True = False x>5 and x>=2 False
False and False = False x>5 and x==6 False
or Returns True if any one True or True = True x<5 or x>1 True
of the operands is True or False = True x>1 or x!=2 True
True. False or True = True x>5 or x>=2 True
False or False = False x>5 or x==6 False
not Reverses the result not True = False not x<5 False
not False = True not x>5 True