SlideShare a Scribd company logo
2
Most read
4
Most read
8
Most read
PYTHON
CLASS: XI
COMPUTER SCIENCE(083)
OPERATORS IN PYTHON
PART-1
OPERATORS:
The operator can be defined as a symbol which is responsible for a particular
operation between two operands. Operators are used to perform operations
on variables and values.
The operator can be defined as a symbol which is responsible for a particular
operation between two operands. Operators are used to perform operations
on variables and values.
Arithmetic operators
Comparison operators
Assignment Operators
Logical Operators
Membership Operators
Identity Operators
Types of Operators
Arithmetic Operators
Arithmetic operators are used with numeric values to perform common
mathematical operations:
Operator Name Example
+ Addition x + y
- Subtraction x - y
* Multiplication x * y
/ Division x / y
// Floor division[Integer Division] x // y
** Exponentiation x ** y
% Modulus x % y
Arithmetic Operators
+ Addition x + y
Example 1:
A=10
B=20
C=A+B
print(“A+B=“,C)
--Output---
A+B=30
Example 2:
A=10
B=20
--Output---
A+B=30
print(“A+B=“,A+B)
Example 3:
A=int(input(“Enter value A:”))
print(“A+B=“,C)
B=int(input(“Enter value B:”))
C=A+B
--Output---
Enter value A: 5
Enter value B: 4
A+B=9
Arithmetic Operators
Example 1:
A=20
B=10
C=A-B
print(“A-B=“,C)
--Output---
A-B=10
Example 2:
A=30
B=20
--Output---
A-B=10
print(“A-B=“,A-B)
Example 3:
A=int(input(“Enter value A:”))
print(“A-B=“,C)
B=int(input(“Enter value B:”))
C=A-B
--Output---
Enter value A: 5
Enter value B: 4
A-B=1
- Subtraction x - y
Arithmetic Operators
Example 1:
A=2
B=10
C=A*B
print(“A*B=“,C)
--Output---
A*B=20
Example 2:
A=3
B=2
--Output---
A*B=6
print(“A*B=“,A*B)
Example 3:
A=int(input(“Enter value A:”))
print(“A*B=“,C)
B=int(input(“Enter value B:”))
C=A*B
--Output---
Enter value A: 5
Enter value B: 4
A*B=20
* Multiplication x * y
Arithmetic Operators
Example 1:
A=27
B=5
C=A/B
print(“A/B=“,C)
--Output---
A/B=5.4
Example 2:
A=27
B=5
--Output---
A//B=5
/ [Division] x / y // Floor division[Integer Division] x // y
C=A//B
print(“A//B=“,C)
Arithmetic Operators
Example 1:
A=27
B=5
C=A%B
print(“A%B=“,C)
--Output---
A%B=2
Example 2:
A=int(input(“Enter the value of A:”))
--Output---
Enter the value of A: 4
Enter the value of B: 2
A%B=0
% [Modulus] x % y : It return remainder value
C=A%B
print(“A%B=“,C)
B=int(input(“Enter the value of B:”))
Arithmetic Operators
Example 1:
A=2
B=3
C=A**B
print(“A**B=“,C)
--Output---
A**B=8
Example 2:
A=int(input(Enter the value of A”))
B=int(input(“Enter the power”))
--Output---
Enter the value of A: 7
Enter the power: 2
A**B=49
C=A**B
print(“A**B=“,C)
** Exponentiation x ** y
Meaning of A**B
AB
Precedence of Arithmetic Operators
Highest
Lowest
() parentheses
** (Exponentiation)
/(division) // (integer division) * ( multiply)
% (modulas)
+ (addition) - ( subtraction)
Expressions:
An expression is a combination of variable and operators. It generates a
single value, which by itself is an expression.
Example:
5 + 2 * 4 and the result is 13
Q. Convert the Mathematical Expressions to equivalent python expressions
Algebraic Expression Python Programming Expression
5A 5 * A
4ab 4 * a * b
A2 + B2 A**2 + B **2
a=(x+y)/(x-y)
20 + 30 * 40
Evaluate the expressions:
1
2
20 + 120
140
20 - 30 + 40
1
2
-10 + 40
30
The two operators (–) and (+)
have equal precedence. Thus,
the first operator, i.e.,
subtraction is applied before
the second operator, i.e.,
addition (left to right).
Evaluate the expressions:
12 + 3 * 4 – 6/2
1
3
4
12 + 12 – 6/2
12 + 12 – 3.0
2
24– 3.0
21.0
(12 + 3) * 4 – 6//2
1
2
4
3 15 * 4 – 6//2
60 – 6//2
60 – 3
57
+ ( plus) and (*) sign for string
+ ( plus) : It is use to concatenation of string and in string case + (plus)
sign is known as concatenation operator.
Example:
If there are two variable A=‘WELCOME’ and B=‘PYTHON’ and we want
to join these two strings.
A=‘WELCOME’
B=‘PYTHON’
print(A+B)
---Output----
WELCOMEPYTHON
It display join or concatenation of
two string but without any gap
+ ( plus) and (*) sign for string
* (multiply) : It is use to repeat the string as many times we need by
multiplying the string with number given.
Example:
If variable A=‘WELCOME’ and we want to display WELCOME 3 times
A=‘WELCOME’
print(A*3)
---Output----
WELCOMEWELCOMEWELCOME

More Related Content

What's hot (20)

PDF
Programming Fundamentals Arrays and Strings
imtiazalijoono
 
PPT
Arrays
fahadshakeel
 
PPTX
USE OF PRINT IN PYTHON PART 2
vikram mahendra
 
DOCX
Maharishi University of Management (MSc Computer Science test questions)
Dharma Kshetri
 
PPTX
Input processing and output in Python
Raajendra M
 
PPT
Arrays
Saranya saran
 
DOCX
C interview question answer 2
Amit Kapoor
 
PPTX
Python programming workshop
BAINIDA
 
PDF
Chap 5 c++
Venkateswarlu Vuggam
 
PPT
Chap 5 c++
Venkateswarlu Vuggam
 
PDF
Simple IO Monad in 'Functional Programming in Scala'
Philip Schwarz
 
PPT
Functions and pointers_unit_4
Saranya saran
 
PPTX
CSE240 Pointers
Garrett Gutierrez
 
PDF
C aptitude scribd
Amit Kapoor
 
DOCX
18 dec pointers and scope resolution operator
SAFFI Ud Din Ahmad
 
PPT
operators and expressions in c++
sanya6900
 
PDF
Operators in python
Prabhakaran V M
 
PPT
Chap 6 c++
Venkateswarlu Vuggam
 
PDF
Chap 6 c++
Venkateswarlu Vuggam
 
Programming Fundamentals Arrays and Strings
imtiazalijoono
 
Arrays
fahadshakeel
 
USE OF PRINT IN PYTHON PART 2
vikram mahendra
 
Maharishi University of Management (MSc Computer Science test questions)
Dharma Kshetri
 
Input processing and output in Python
Raajendra M
 
C interview question answer 2
Amit Kapoor
 
Python programming workshop
BAINIDA
 
Simple IO Monad in 'Functional Programming in Scala'
Philip Schwarz
 
Functions and pointers_unit_4
Saranya saran
 
CSE240 Pointers
Garrett Gutierrez
 
C aptitude scribd
Amit Kapoor
 
18 dec pointers and scope resolution operator
SAFFI Ud Din Ahmad
 
operators and expressions in c++
sanya6900
 
Operators in python
Prabhakaran V M
 

Similar to OPERATOR IN PYTHON-PART1 (20)

PPTX
Python Operators.pptx
adityakumawat625
 
PPTX
Python Programming | JNTUK | UNIT 1 | Lecture 5
FabMinds
 
PPTX
Lecture 05.pptx
Mohammad Hassan
 
PPTX
PYTHON OPERATORS 123Python Operators.pptx
AnjaneyuluKunchala1
 
PPTX
Python Operators
Adheetha O. V
 
PPTX
Python programming language introduction unit
michaelaaron25322
 
PDF
python2oxhvoudhuSGFsughusgdogusuosFU.pdf
rohithzach
 
PDF
Python (high level programming ) language
worldeader
 
PPTX
MODULE. .pptx
Alpha337901
 
PDF
Operators in python
eShikshak
 
PPTX
Session 4.pptx
YogeshwariK10
 
PPTX
Operators in Python
Anusuya123
 
PPTX
OPERATORS-PYTHON.pptx ALL OPERATORS ARITHMATIC AND LOGICAL
NagarathnaRajur2
 
PPTX
Python operators
nuripatidar
 
PDF
Variables in Python & Data Types and Their Values
Raza Ul Mustafa
 
PPTX
operatorsinpython-18112209560412 (1).pptx
urvashipundir04
 
PPTX
Python-Operators-and-Type-Conversion.pptx
teamfnatic28
 
PPTX
Operators in python
deepalishinkar1
 
PDF
Python Operators.pdf
SudhanshiBakre1
 
PDF
Python : basic operators
S.M. Salaquzzaman
 
Python Operators.pptx
adityakumawat625
 
Python Programming | JNTUK | UNIT 1 | Lecture 5
FabMinds
 
Lecture 05.pptx
Mohammad Hassan
 
PYTHON OPERATORS 123Python Operators.pptx
AnjaneyuluKunchala1
 
Python Operators
Adheetha O. V
 
Python programming language introduction unit
michaelaaron25322
 
python2oxhvoudhuSGFsughusgdogusuosFU.pdf
rohithzach
 
Python (high level programming ) language
worldeader
 
MODULE. .pptx
Alpha337901
 
Operators in python
eShikshak
 
Session 4.pptx
YogeshwariK10
 
Operators in Python
Anusuya123
 
OPERATORS-PYTHON.pptx ALL OPERATORS ARITHMATIC AND LOGICAL
NagarathnaRajur2
 
Python operators
nuripatidar
 
Variables in Python & Data Types and Their Values
Raza Ul Mustafa
 
operatorsinpython-18112209560412 (1).pptx
urvashipundir04
 
Python-Operators-and-Type-Conversion.pptx
teamfnatic28
 
Operators in python
deepalishinkar1
 
Python Operators.pdf
SudhanshiBakre1
 
Python : basic operators
S.M. Salaquzzaman
 
Ad

More from vikram mahendra (20)

PPTX
Communication skill
vikram mahendra
 
PDF
Python Project On Cosmetic Shop system
vikram mahendra
 
PDF
Python Project on Computer Shop
vikram mahendra
 
PDF
PYTHON PROJECT ON CARSHOP SYSTEM
vikram mahendra
 
PDF
BOOK SHOP SYSTEM Project in Python
vikram mahendra
 
PPTX
FLOWOFCONTROL-IF..ELSE PYTHON
vikram mahendra
 
PPTX
FLOW OF CONTROL-INTRO PYTHON
vikram mahendra
 
PPTX
Python Introduction
vikram mahendra
 
PPTX
GREEN SKILL[PART-2]
vikram mahendra
 
PPTX
GREEN SKILLS[PART-1]
vikram mahendra
 
PPTX
Dictionary in python
vikram mahendra
 
PPTX
Entrepreneurial skills
vikram mahendra
 
PPTX
Boolean logic
vikram mahendra
 
PPTX
Tuple in python
vikram mahendra
 
PPTX
LIST IN PYTHON[SELECTION SORT]
vikram mahendra
 
PPTX
DATA REPRESENTATION-NUMBER SYSTEM-PART-5
vikram mahendra
 
PPTX
DATA REPRESENTATION-NUMBER SYSTEM
vikram mahendra
 
PPTX
LIST IN PYTHON[BUBBLE SORT]
vikram mahendra
 
PPTX
Internet,its applications and services
vikram mahendra
 
PPTX
DATA REPRESENTATION [NUMBER SYSTEM]
vikram mahendra
 
Communication skill
vikram mahendra
 
Python Project On Cosmetic Shop system
vikram mahendra
 
Python Project on Computer Shop
vikram mahendra
 
PYTHON PROJECT ON CARSHOP SYSTEM
vikram mahendra
 
BOOK SHOP SYSTEM Project in Python
vikram mahendra
 
FLOWOFCONTROL-IF..ELSE PYTHON
vikram mahendra
 
FLOW OF CONTROL-INTRO PYTHON
vikram mahendra
 
Python Introduction
vikram mahendra
 
GREEN SKILL[PART-2]
vikram mahendra
 
GREEN SKILLS[PART-1]
vikram mahendra
 
Dictionary in python
vikram mahendra
 
Entrepreneurial skills
vikram mahendra
 
Boolean logic
vikram mahendra
 
Tuple in python
vikram mahendra
 
LIST IN PYTHON[SELECTION SORT]
vikram mahendra
 
DATA REPRESENTATION-NUMBER SYSTEM-PART-5
vikram mahendra
 
DATA REPRESENTATION-NUMBER SYSTEM
vikram mahendra
 
LIST IN PYTHON[BUBBLE SORT]
vikram mahendra
 
Internet,its applications and services
vikram mahendra
 
DATA REPRESENTATION [NUMBER SYSTEM]
vikram mahendra
 
Ad

Recently uploaded (20)

PPTX
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
PPTX
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
PPTX
Difference between write and update in odoo 18
Celine George
 
PPTX
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PDF
Council of Chalcedon Re-Examined
Smiling Lungs
 
PDF
Introduction presentation of the patentbutler tool
MIPLM
 
PPTX
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
Introduction to Indian Writing in English
Trushali Dodiya
 
PPTX
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PDF
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
PDF
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PDF
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
Identifying elements in the story. Arrange the events in the story
geraldineamahido2
 
Difference between write and update in odoo 18
Celine George
 
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
Council of Chalcedon Re-Examined
Smiling Lungs
 
Introduction presentation of the patentbutler tool
MIPLM
 
How to Create Odoo JS Dialog_Popup in Odoo 18
Celine George
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Introduction to Indian Writing in English
Trushali Dodiya
 
DIGITAL CITIZENSHIP TOPIC TLE 8 MATATAG CURRICULUM
ROBERTAUGUSTINEFRANC
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
Characteristics, Strengths and Weaknesses of Quantitative Research.pdf
Thelma Villaflores
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
Knee Extensor Mechanism Injuries - Orthopedic Radiologic Imaging
Sean M. Fox
 

OPERATOR IN PYTHON-PART1

  • 2. OPERATORS: The operator can be defined as a symbol which is responsible for a particular operation between two operands. Operators are used to perform operations on variables and values. The operator can be defined as a symbol which is responsible for a particular operation between two operands. Operators are used to perform operations on variables and values. Arithmetic operators Comparison operators Assignment Operators Logical Operators Membership Operators Identity Operators Types of Operators
  • 3. Arithmetic Operators Arithmetic operators are used with numeric values to perform common mathematical operations: Operator Name Example + Addition x + y - Subtraction x - y * Multiplication x * y / Division x / y // Floor division[Integer Division] x // y ** Exponentiation x ** y % Modulus x % y
  • 4. Arithmetic Operators + Addition x + y Example 1: A=10 B=20 C=A+B print(“A+B=“,C) --Output--- A+B=30 Example 2: A=10 B=20 --Output--- A+B=30 print(“A+B=“,A+B) Example 3: A=int(input(“Enter value A:”)) print(“A+B=“,C) B=int(input(“Enter value B:”)) C=A+B --Output--- Enter value A: 5 Enter value B: 4 A+B=9
  • 5. Arithmetic Operators Example 1: A=20 B=10 C=A-B print(“A-B=“,C) --Output--- A-B=10 Example 2: A=30 B=20 --Output--- A-B=10 print(“A-B=“,A-B) Example 3: A=int(input(“Enter value A:”)) print(“A-B=“,C) B=int(input(“Enter value B:”)) C=A-B --Output--- Enter value A: 5 Enter value B: 4 A-B=1 - Subtraction x - y
  • 6. Arithmetic Operators Example 1: A=2 B=10 C=A*B print(“A*B=“,C) --Output--- A*B=20 Example 2: A=3 B=2 --Output--- A*B=6 print(“A*B=“,A*B) Example 3: A=int(input(“Enter value A:”)) print(“A*B=“,C) B=int(input(“Enter value B:”)) C=A*B --Output--- Enter value A: 5 Enter value B: 4 A*B=20 * Multiplication x * y
  • 7. Arithmetic Operators Example 1: A=27 B=5 C=A/B print(“A/B=“,C) --Output--- A/B=5.4 Example 2: A=27 B=5 --Output--- A//B=5 / [Division] x / y // Floor division[Integer Division] x // y C=A//B print(“A//B=“,C)
  • 8. Arithmetic Operators Example 1: A=27 B=5 C=A%B print(“A%B=“,C) --Output--- A%B=2 Example 2: A=int(input(“Enter the value of A:”)) --Output--- Enter the value of A: 4 Enter the value of B: 2 A%B=0 % [Modulus] x % y : It return remainder value C=A%B print(“A%B=“,C) B=int(input(“Enter the value of B:”))
  • 9. Arithmetic Operators Example 1: A=2 B=3 C=A**B print(“A**B=“,C) --Output--- A**B=8 Example 2: A=int(input(Enter the value of A”)) B=int(input(“Enter the power”)) --Output--- Enter the value of A: 7 Enter the power: 2 A**B=49 C=A**B print(“A**B=“,C) ** Exponentiation x ** y Meaning of A**B AB
  • 10. Precedence of Arithmetic Operators Highest Lowest () parentheses ** (Exponentiation) /(division) // (integer division) * ( multiply) % (modulas) + (addition) - ( subtraction)
  • 11. Expressions: An expression is a combination of variable and operators. It generates a single value, which by itself is an expression. Example: 5 + 2 * 4 and the result is 13 Q. Convert the Mathematical Expressions to equivalent python expressions Algebraic Expression Python Programming Expression 5A 5 * A 4ab 4 * a * b A2 + B2 A**2 + B **2 a=(x+y)/(x-y)
  • 12. 20 + 30 * 40 Evaluate the expressions: 1 2 20 + 120 140 20 - 30 + 40 1 2 -10 + 40 30 The two operators (–) and (+) have equal precedence. Thus, the first operator, i.e., subtraction is applied before the second operator, i.e., addition (left to right).
  • 13. Evaluate the expressions: 12 + 3 * 4 – 6/2 1 3 4 12 + 12 – 6/2 12 + 12 – 3.0 2 24– 3.0 21.0 (12 + 3) * 4 – 6//2 1 2 4 3 15 * 4 – 6//2 60 – 6//2 60 – 3 57
  • 14. + ( plus) and (*) sign for string + ( plus) : It is use to concatenation of string and in string case + (plus) sign is known as concatenation operator. Example: If there are two variable A=‘WELCOME’ and B=‘PYTHON’ and we want to join these two strings. A=‘WELCOME’ B=‘PYTHON’ print(A+B) ---Output---- WELCOMEPYTHON It display join or concatenation of two string but without any gap
  • 15. + ( plus) and (*) sign for string * (multiply) : It is use to repeat the string as many times we need by multiplying the string with number given. Example: If variable A=‘WELCOME’ and we want to display WELCOME 3 times A=‘WELCOME’ print(A*3) ---Output---- WELCOMEWELCOMEWELCOME