0% found this document useful (0 votes)
6 views2 pages

Python Operators Notes-3

This document provides an overview of operators in Python, including arithmetic, assignment, comparison, and logical operators. It explains the function of each operator type with examples and their outputs. The learning objective is to enable users to effectively use and describe different operators in Python programs.
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)
6 views2 pages

Python Operators Notes-3

This document provides an overview of operators in Python, including arithmetic, assignment, comparison, and logical operators. It explains the function of each operator type with examples and their outputs. The learning objective is to enable users to effectively use and describe different operators in Python programs.
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/ 2

PYTHON – OPERATORS in PYTHON

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

+= Addition Assignment x+=2 x=x+2 7

-= Subtraction Assignment x-=2 x=x-2 3

*= Multiplication Assignment x*=2 x=x*2 10

/= Division Assignment x/=2 x=x/5 2.5

%= Remainder Assignment x%=3 x=x%3 2

//= Floor Division Assignment x//=3 x=x//3 1


**= Exponentiation Assignment x**=2 x=x**2 25
3. Comparison (Relational) Operators
• Relational operators are used to compare values and determine the relationship between them.
• Return either ‘True’ or ‘False’ according to the condition.
Operator Name Example Output
(x=8 and y=6)
== Equal To x==y False
!= Not Equal To x!=y True
> Greater Than x>y True
>= Greater Than or Equal To x>=y True
< Less Than x<y False
<= Less Than or Equal To x<=y False

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

You might also like