SlideShare a Scribd company logo
1 of 15
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

Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings imtiazalijoono
 
USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2vikram mahendra
 
Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)Dharma Kshetri
 
Input processing and output in Python
Input processing and output in PythonInput processing and output in Python
Input processing and output in PythonRaajendra M
 
C interview question answer 2
C interview question answer 2C interview question answer 2
C interview question answer 2Amit Kapoor
 
Python programming workshop
Python programming workshopPython programming workshop
Python programming workshopBAINIDA
 
Simple IO Monad in 'Functional Programming in Scala'
Simple IO Monad in 'Functional Programming in Scala'Simple IO Monad in 'Functional Programming in Scala'
Simple IO Monad in 'Functional Programming in Scala'Philip Schwarz
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4Saranya saran
 
C aptitude scribd
C aptitude scribdC aptitude scribd
C aptitude scribdAmit Kapoor
 
18 dec pointers and scope resolution operator
18 dec pointers and scope resolution operator18 dec pointers and scope resolution operator
18 dec pointers and scope resolution operatorSAFFI Ud Din Ahmad
 
operators and expressions in c++
 operators and expressions in c++ operators and expressions in c++
operators and expressions in c++sanya6900
 

What's hot (20)

Programming Fundamentals Arrays and Strings
Programming Fundamentals   Arrays and Strings Programming Fundamentals   Arrays and Strings
Programming Fundamentals Arrays and Strings
 
Arrays
ArraysArrays
Arrays
 
USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2USE OF PRINT IN PYTHON PART 2
USE OF PRINT IN PYTHON PART 2
 
Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)
 
Python : Operators
Python : OperatorsPython : Operators
Python : Operators
 
Input processing and output in Python
Input processing and output in PythonInput processing and output in Python
Input processing and output in Python
 
Arrays
ArraysArrays
Arrays
 
C interview question answer 2
C interview question answer 2C interview question answer 2
C interview question answer 2
 
Python programming workshop
Python programming workshopPython programming workshop
Python programming workshop
 
Chap 5 c++
Chap 5 c++Chap 5 c++
Chap 5 c++
 
Chap 5 c++
Chap 5 c++Chap 5 c++
Chap 5 c++
 
Simple IO Monad in 'Functional Programming in Scala'
Simple IO Monad in 'Functional Programming in Scala'Simple IO Monad in 'Functional Programming in Scala'
Simple IO Monad in 'Functional Programming in Scala'
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 
CSE240 Pointers
CSE240 PointersCSE240 Pointers
CSE240 Pointers
 
C aptitude scribd
C aptitude scribdC aptitude scribd
C aptitude scribd
 
18 dec pointers and scope resolution operator
18 dec pointers and scope resolution operator18 dec pointers and scope resolution operator
18 dec pointers and scope resolution operator
 
operators and expressions in c++
 operators and expressions in c++ operators and expressions in c++
operators and expressions in c++
 
Operators in python
Operators in pythonOperators in python
Operators in python
 
Chap 6 c++
Chap 6 c++Chap 6 c++
Chap 6 c++
 
Chap 6 c++
Chap 6 c++Chap 6 c++
Chap 6 c++
 

Similar to OPERATOR IN PYTHON-PART1

Cse lecture-4.1-c operators and expression
Cse lecture-4.1-c operators and expressionCse lecture-4.1-c operators and expression
Cse lecture-4.1-c operators and expressionFarshidKhan
 
Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++bajiajugal
 
Class_IX_Operators.pptx
Class_IX_Operators.pptxClass_IX_Operators.pptx
Class_IX_Operators.pptxrinkugupta37
 
This slide contains information about Operators in C.pptx
This slide contains information about Operators in C.pptxThis slide contains information about Operators in C.pptx
This slide contains information about Operators in C.pptxranaashutosh531pvt
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c languageTanmay Modi
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c languagetanmaymodi4
 
Operators and Expressions in C++
Operators and Expressions in C++Operators and Expressions in C++
Operators and Expressions in C++Praveen M Jigajinni
 
Dti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpressionDti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpressionalish sha
 
C programming session 02
C programming session 02C programming session 02
C programming session 02Dushmanta Nath
 
Operators in Python
Operators in PythonOperators in Python
Operators in PythonAnusuya123
 
Chapter 3.3
Chapter 3.3Chapter 3.3
Chapter 3.3sotlsoc
 
Arithmetic and increment decrement Operator
Arithmetic and increment decrement OperatorArithmetic and increment decrement Operator
Arithmetic and increment decrement OperatorMegha Sharma
 
C++ revision add on till now
C++ revision add on till nowC++ revision add on till now
C++ revision add on till nowAmAn Singh
 
C++ revision add on till now
C++ revision add on till nowC++ revision add on till now
C++ revision add on till nowAmAn Singh
 

Similar to OPERATOR IN PYTHON-PART1 (20)

Coper in C
Coper in CCoper in C
Coper in C
 
Cse lecture-4.1-c operators and expression
Cse lecture-4.1-c operators and expressionCse lecture-4.1-c operators and expression
Cse lecture-4.1-c operators and expression
 
Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++
 
C – operators and expressions
C – operators and expressionsC – operators and expressions
C – operators and expressions
 
Class_IX_Operators.pptx
Class_IX_Operators.pptxClass_IX_Operators.pptx
Class_IX_Operators.pptx
 
This slide contains information about Operators in C.pptx
This slide contains information about Operators in C.pptxThis slide contains information about Operators in C.pptx
This slide contains information about Operators in C.pptx
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c language
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
Operators and Expressions in C++
Operators and Expressions in C++Operators and Expressions in C++
Operators and Expressions in C++
 
Dti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpressionDti2143 chapter 3 arithmatic relation-logicalexpression
Dti2143 chapter 3 arithmatic relation-logicalexpression
 
C programming session 02
C programming session 02C programming session 02
C programming session 02
 
Operators in Python
Operators in PythonOperators in Python
Operators in Python
 
Chapter 3.3
Chapter 3.3Chapter 3.3
Chapter 3.3
 
Arithmetic and increment decrement Operator
Arithmetic and increment decrement OperatorArithmetic and increment decrement Operator
Arithmetic and increment decrement Operator
 
Arithmetic operator
Arithmetic operatorArithmetic operator
Arithmetic operator
 
Arithmetic operator
Arithmetic operatorArithmetic operator
Arithmetic operator
 
05 operators
05   operators05   operators
05 operators
 
C++ revision add on till now
C++ revision add on till nowC++ revision add on till now
C++ revision add on till now
 
C++ revision add on till now
C++ revision add on till nowC++ revision add on till now
C++ revision add on till now
 
Opeartor & expression
Opeartor & expressionOpeartor & expression
Opeartor & expression
 

More from vikram mahendra

Python Project On Cosmetic Shop system
Python Project On Cosmetic Shop systemPython Project On Cosmetic Shop system
Python Project On Cosmetic Shop systemvikram mahendra
 
Python Project on Computer Shop
Python Project on Computer ShopPython Project on Computer Shop
Python Project on Computer Shopvikram mahendra
 
PYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEMPYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEMvikram mahendra
 
BOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in PythonBOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in Pythonvikram mahendra
 
FLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHONFLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHONvikram mahendra
 
FLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONFLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONvikram mahendra
 
LIST IN PYTHON[SELECTION SORT]
LIST IN PYTHON[SELECTION SORT]LIST IN PYTHON[SELECTION SORT]
LIST IN PYTHON[SELECTION SORT]vikram mahendra
 
DATA REPRESENTATION-NUMBER SYSTEM-PART-5
DATA REPRESENTATION-NUMBER SYSTEM-PART-5DATA REPRESENTATION-NUMBER SYSTEM-PART-5
DATA REPRESENTATION-NUMBER SYSTEM-PART-5vikram mahendra
 
DATA REPRESENTATION-NUMBER SYSTEM
DATA REPRESENTATION-NUMBER SYSTEMDATA REPRESENTATION-NUMBER SYSTEM
DATA REPRESENTATION-NUMBER SYSTEMvikram mahendra
 
LIST IN PYTHON[BUBBLE SORT]
LIST IN PYTHON[BUBBLE SORT]LIST IN PYTHON[BUBBLE SORT]
LIST IN PYTHON[BUBBLE SORT]vikram mahendra
 
Internet,its applications and services
Internet,its applications and servicesInternet,its applications and services
Internet,its applications and servicesvikram mahendra
 
DATA REPRESENTATION [NUMBER SYSTEM]
DATA REPRESENTATION [NUMBER SYSTEM]DATA REPRESENTATION [NUMBER SYSTEM]
DATA REPRESENTATION [NUMBER SYSTEM]vikram mahendra
 

More from vikram mahendra (20)

Communication skill
Communication skillCommunication skill
Communication skill
 
Python Project On Cosmetic Shop system
Python Project On Cosmetic Shop systemPython Project On Cosmetic Shop system
Python Project On Cosmetic Shop system
 
Python Project on Computer Shop
Python Project on Computer ShopPython Project on Computer Shop
Python Project on Computer Shop
 
PYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEMPYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEM
 
BOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in PythonBOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in Python
 
FLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHONFLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHON
 
FLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONFLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHON
 
Python Introduction
Python IntroductionPython Introduction
Python Introduction
 
GREEN SKILL[PART-2]
GREEN SKILL[PART-2]GREEN SKILL[PART-2]
GREEN SKILL[PART-2]
 
GREEN SKILLS[PART-1]
GREEN SKILLS[PART-1]GREEN SKILLS[PART-1]
GREEN SKILLS[PART-1]
 
Dictionary in python
Dictionary in pythonDictionary in python
Dictionary in python
 
Entrepreneurial skills
Entrepreneurial skillsEntrepreneurial skills
Entrepreneurial skills
 
Boolean logic
Boolean logicBoolean logic
Boolean logic
 
Tuple in python
Tuple in pythonTuple in python
Tuple in python
 
LIST IN PYTHON[SELECTION SORT]
LIST IN PYTHON[SELECTION SORT]LIST IN PYTHON[SELECTION SORT]
LIST IN PYTHON[SELECTION SORT]
 
DATA REPRESENTATION-NUMBER SYSTEM-PART-5
DATA REPRESENTATION-NUMBER SYSTEM-PART-5DATA REPRESENTATION-NUMBER SYSTEM-PART-5
DATA REPRESENTATION-NUMBER SYSTEM-PART-5
 
DATA REPRESENTATION-NUMBER SYSTEM
DATA REPRESENTATION-NUMBER SYSTEMDATA REPRESENTATION-NUMBER SYSTEM
DATA REPRESENTATION-NUMBER SYSTEM
 
LIST IN PYTHON[BUBBLE SORT]
LIST IN PYTHON[BUBBLE SORT]LIST IN PYTHON[BUBBLE SORT]
LIST IN PYTHON[BUBBLE SORT]
 
Internet,its applications and services
Internet,its applications and servicesInternet,its applications and services
Internet,its applications and services
 
DATA REPRESENTATION [NUMBER SYSTEM]
DATA REPRESENTATION [NUMBER SYSTEM]DATA REPRESENTATION [NUMBER SYSTEM]
DATA REPRESENTATION [NUMBER SYSTEM]
 

Recently uploaded

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 

Recently uploaded (20)

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 

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