0% found this document useful (0 votes)
15 views5 pages

Python Notes by Rishabh Mishra Chap-08-Operators

python learning

Uploaded by

Mihirvashishtha
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)
15 views5 pages

Python Notes by Rishabh Mishra Chap-08-Operators

python learning

Uploaded by

Mihirvashishtha
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/ 5

PYTHON TUTORIAL FOR BEGINNERS

Source: www.youtube.com/@RishabhMishraOfficial

Chapter - 08

Operators in Python
• What are Operators
• Types of Operators
• Operators Examples

Operators in Python
Operators in Python are special symbols or keywords used to perform
operations on operands (variables and values).
Operators: These are the special symbols/keywords. Eg: + , * , /, etc.
Operand: It is the value on which the operator is applied.
# Examples
Addition operator '+': a + b
Equal operator '==': a == b
and operator 'and': a > 10 and b < 20

Types of Operators
Python supports various types of operators, which can be broadly categorized as:
1. Arithmetic Operators
2. Comparison (Relational) Operators
3. Assignment Operators
4. Logical Operators
5. Bitwise Operators
6. Identity Operators
7. Membership Operators

P y t h o n N o t e s b y R i s h a b h M i s h ra
Operators Cheat Sheet

Operator Description
() Parentheses
** Exponentiation
+, -, ~ Positive, Negative, Bitwise NOT
*, /, //, % Multiplication, Division, Floor Division, Modulus
+, - Addition, Subtraction
==, !=, >, >=, <, <= Comparison operators
is, is not, in, not in Identity, Membership Operators
NOT, AND, OR Logical NOT, Logical AND, Logical OR
<<, >> Bitwise Left Shift, Bitwise Right Shift
&, ^, | Bitwise AND, Bitwise XOR, Bitwise OR

1. Arithmetic Operators
Arithmetic operators are used with numeric values to perform mathematical
operations such as addition, subtraction, multiplication, and division.

P y t h o n N o t e s b y R i s h a b h M i s h ra
Precedence of Arithmetic Operators in Python:
P – Parentheses
E – Exponentiation
M – Multiplication
D – Division
A – Addition
S – Subtraction

2. Comparison (Relational) Operators


Comparison operators are used to compare two values and return a Boolean
result (True or False).

3. Assignment Operators
Assignment operators are used to assign values to variables.

P y t h o n N o t e s b y R i s h a b h M i s h ra
4. Logical Operators
Logical operators are used to combine conditional statements.

5. Identity & Membership Operators


Identity operators are used to compare the memory locations of two objects, not
just equal but if they are the same objects.
Membership operators checks whether a given value is a member of a sequence
(such as strings, lists, and tuples) or not.

6. Bitwise Operators
Bitwise operators perform operations on binary numbers.

P y t h o n N o t e s b y R i s h a b h M i s h ra
Bitwise Operators Example:
# Compare each bit in these numbers. Eg:1

0101 (This is 5 in binary) a = 5 # 0101


0011 (This is 3 in binary) b = 3 # 0011
------- print(a & b)
0001 (This is the result of 5 & 3) # Output: 1 # 0001

# Rules: 0 – False, 1 - True Eg:2


True + True = True a = 5 # 0101
True + False = False b = 8 # 1000
False + False = False print(a & b)
# Output: 0 # 0000

Python Tutorial Playlist: Click Here


https://www.youtube.com/playlist?list=PLdOKnrf8EcP384Ilxra4UlK9BDJGwawg9

P y t h o n N o t e s b y R i s h a b h M i s h ra

You might also like