SlideShare a Scribd company logo
CLASS: XI
COMPUTER SCIENCE(083)
OPERATORS IN PYTHON
Comparison operators and Assignment Operators
PART-2
Assignment Operators
Assignment operators are used to assign values to variables:
Example: What it does? Shortcut method
x=10
x + = 1
# It add 1 to x and assign value to x
(left side)x=x+1
print(“x=“,x)
x=10
print(“x=“,x)
-----OUTPUT-----
x= 11
=( equal to)
Assignment Operators
If you want to subtract the value store inside the variable.
Example: What it does? Shortcut method
x=10
x - = 1
# It subtract 1 from x and assign value
to x (left side)x=x-1
print(“x=“,x)
x=10
print(“x=“,x)
-----OUTPUT-----
x= 9
Assignment Operators
If you want to multiply(*) the value store inside the variable by 3.
Example: What it does? Shortcut method
x=10
x * = 3
# It Multiply 3 with x and assign value
to x (left side)x=x*3
print(“x=“,x)
x=10
print(“x=“,x)
-----OUTPUT-----
x= 30
Assignment Operators
If you want to Divide(/ or //) the value store inside the variable by 2.
Example: What it does? Shortcut method
x=10
x / = 2# It x or y divide by 2 and assign value
to x or y (left side)
x=x/2
print(“x=“,x)
x=10
print(“x=“,x)-----OUTPUT-----
x= 5.0
y=5
y // = 2y=y//2
print(“y=“,y) print(“y=“,y)
y=10 y=10
Assignment Operators
If you want Modulus(%) of the value.
Example: Shortcut method
x=10
x % = 3x=x%3
print(“x=“,x)
x=10
print(“x=“,x)
-----OUTPUT-----
x= 1
If you want Exponential(**) of the
value.
Example: Shortcut method
x=3
x ** = 2x=x**2
print(“x=“,x)
x=3
print(“x=“,x)
-----OUTPUT-----
x= 9
Relational or Comparison Operators
Comparison operators are used to compare two values. Comparison operators
are used to comparing the value of the two operands and returns Boolean true
or false
Operator: Description
==
!=
If the value of two operands is equal, then the condition becomes true.
If the value of two operands is not equal, then the condition becomes true.
<
Example:
If the first operand is less than the second operand, then the condition becomes true.
<= If the first operand is less than or equal to the second operand, then the
condition becomes true
> If the first operand is greater than the second operand, then the condition becomes true.
>= If the first operand is greater than or equal to the second operand, then the condition
becomes true.
X==Y
X!=Y
X<Y
X<=Y
X>Y
X>=Y
Relational or Comparison Operators
Program to check all the relational operator working in python.
x=10
y=20
print(“x==y:”,x==y)
print(“x!=y:”,x!=y)
print(“x<y:”,x<y)
print(“x<=y:”,x<=y)
print(“x>y:”,x>y)
print(“x>=y:”,x>=y)
-----OUTPUT-----
x==y: False
x!=y: True
x<y: True
x<=y: True
x>y: False
x>=y: False
Logical Operators
Logical operators are used to combine conditional statements:
and or not
Returns True if
both statements
are true
Returns True if one of
the statements is true
Reverse the result,
returns False if the result
is true
A B A and B
T T T
T F F
F T F
F F F
A B A OR B
T T T
T F T
F T T
F F F
A NOT A
T F
F T
Logical Operators
x=40
y=20
z=5
print(x>y and x==z)
and or not
x=40
y=20
z=5
print(x>y or x==z)
x=40
y=20
print(not (x>y))
--Output----
False
--Output----
True
--Output----
False
Logical Operators
Write the output of the expression given below:
A=10 , B=5 , C=3 , D=-5
((A>B) OR (B!=C)) AND (NOT(A!=C) AND (C>B))
((10>5) OR (5!=3)) AND (NOT(10!=3) AND (3>5))
((T) OR (T)) AND (NOT(T) AND (F))
(TRUE) AND (FALSE AND FALSE)
(TRUE) AND (FALSE)
FALSE
Identity Operators
Identity Operators in Python are used to compare the memory location of two
objects. Identity operator (“is” and “is not”) is used to compare the object’s
memory location. When an object is created in memory a unique memory
address is allocated to that object.
is is not
It returns true if
two variables point
the same object
and false otherwise
It returns false if two
variables point the
same object and true
otherwise
is operator:
x = 5
print(type(x) is int)
--Output----
True
x = 5
print(type(x) is float)
Output: False
is not operator:
x = 5
print(type(x) is not int)
--Output----
False
x = 5
print(type(x) is not float)
Output: True
Example: If we declare three variable to store name “Mohit”,”Rohit”,and again
“Mohit”, then use == operator of check these names equality.
nm1=‘Mohit’
nm2=‘Rohit’
nm3=‘Mohit’
print(nm1==nm2)
print(nm2==nm3)
print(nm1==nm2)
Comparison operator “==” to check if both the
object values are the same.
----Output-----
False
False
True
Example: If we declare two variable a, b and store same number 10 and then
use is or is not identity operator.
a=10
b=10
print(a is b)
----Output-----
True
a=10
b=20
print(a is b)
----Output-----
False
Example: If we declare three variable to store name “Mohit”,”Rohit”,and again
“Mohit”, They are usually used to determine the type of data a certain variable
contains.
nm1=‘Mohit’
nm2=‘Rohit’
nm3=‘Mohit’
print(nm1 is nm2)
print(nm2 is nm3)
print(nm1 is nm2)
----Output-----
False
False
True
print(nm1 is not nm2)
print(nm2 is not nm3)
print(nm1 is not nm2)
----Output-----
True
True
False
Example: If we declare three variable to store name “Mohit”,”Rohit”,and again
“Mohit”, They are usually used to determine the type of data a certain variable
contains.
nm1=‘Mohit’
nm2=‘Rohit’
nm3=‘Mohit’
The built-in id() a function is used to get the “identity” of
an object.
print(“nm1 memory address:”,id(nm1))
print(“nm2 memory address:”,id(nm2))
print(“nm3 memory address:”,id(nm3))
----Output-----
nm1 memory address :45891616
nm2 memory address :45891648
nm3 memory address :45891616
So that is why nm1 is nm3 show : True And nm1 is nm2 show : False
Now let Us understand that why nm1 and nm3 memory address are same and
nm2 is different.
Memory
Mohit Rohit
nm1 nm2 nm3
nm1=‘Mohit’ nm2=‘Rohit’ nm3=‘Mohit’
Instead of creating a separate object nm3 ,It will act as a pointer pointing to
nm1 which hold the same value
create create
Membership Operators
Python’s membership operators test for membership in a sequence, such
as strings, lists, or tuples.
in not in
Evaluates to true if it finds a
variable in the specified
sequence and false
otherwise.
Evaluates to true if it does not
finds a variable in the specified
sequence and false otherwise
x = 'Hello world'
Membership Operators
in operator:
Let us understand the in operator with the help of example
print('H' in x)
--Output--
True
print(‘hello' in x) True
print(‘World' in x) False

More Related Content

What's hot

Chapter 1 Basic Programming (Python Programming Lecture)
Chapter 1 Basic Programming (Python Programming Lecture)Chapter 1 Basic Programming (Python Programming Lecture)
Chapter 1 Basic Programming (Python Programming Lecture)
IoT Code Lab
 
Functions
FunctionsFunctions
Recursion
RecursionRecursion
Recursion
Malainine Zaid
 
Functional Core and Imperative Shell - Game of Life Example - Haskell and Scala
Functional Core and Imperative Shell - Game of Life Example - Haskell and ScalaFunctional Core and Imperative Shell - Game of Life Example - Haskell and Scala
Functional Core and Imperative Shell - Game of Life Example - Haskell and Scala
Philip Schwarz
 
Looping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonLooping Statements and Control Statements in Python
Looping Statements and Control Statements in Python
PriyankaC44
 
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
Edureka!
 
A Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIOA Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIO
Jorge Vásquez
 
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
Philip Schwarz
 
What is Multithreading In Python | Python Multithreading Tutorial | Edureka
What is Multithreading In Python | Python Multithreading Tutorial | EdurekaWhat is Multithreading In Python | Python Multithreading Tutorial | Edureka
What is Multithreading In Python | Python Multithreading Tutorial | Edureka
Edureka!
 
Date and Time Module in Python | Edureka
Date and Time Module in Python | EdurekaDate and Time Module in Python | Edureka
Date and Time Module in Python | Edureka
Edureka!
 
Python for loop
Python for loopPython for loop
Python for loop
Aishwarya Deshmukh
 
Lesson 2 derivative of inverse trigonometric functions
Lesson 2 derivative of inverse trigonometric functionsLesson 2 derivative of inverse trigonometric functions
Lesson 2 derivative of inverse trigonometric functions
Lawrence De Vera
 
USER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHONUSER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHON
vikram mahendra
 
Python datetime
Python datetimePython datetime
Python datetime
sureshraj43
 
Python Lab manual program for BE First semester (all department
Python Lab manual program for BE First semester (all departmentPython Lab manual program for BE First semester (all department
Python Lab manual program for BE First semester (all department
Nazeer Wahab
 
The chain rule
The chain ruleThe chain rule
The chain rule
J M
 
Python programming : Exceptions
Python programming : ExceptionsPython programming : Exceptions
Python programming : Exceptions
Emertxe Information Technologies Pvt Ltd
 
What is Python Lambda Function? Python Tutorial | Edureka
What is Python Lambda Function? Python Tutorial | EdurekaWhat is Python Lambda Function? Python Tutorial | Edureka
What is Python Lambda Function? Python Tutorial | Edureka
Edureka!
 
Programación Funcional 101 con Scala y ZIO 2.0
Programación Funcional 101 con Scala y ZIO 2.0Programación Funcional 101 con Scala y ZIO 2.0
Programación Funcional 101 con Scala y ZIO 2.0
Jorge Vásquez
 

What's hot (20)

Chapter 1 Basic Programming (Python Programming Lecture)
Chapter 1 Basic Programming (Python Programming Lecture)Chapter 1 Basic Programming (Python Programming Lecture)
Chapter 1 Basic Programming (Python Programming Lecture)
 
Functions
FunctionsFunctions
Functions
 
Recursion DM
Recursion DMRecursion DM
Recursion DM
 
Recursion
RecursionRecursion
Recursion
 
Functional Core and Imperative Shell - Game of Life Example - Haskell and Scala
Functional Core and Imperative Shell - Game of Life Example - Haskell and ScalaFunctional Core and Imperative Shell - Game of Life Example - Haskell and Scala
Functional Core and Imperative Shell - Game of Life Example - Haskell and Scala
 
Looping Statements and Control Statements in Python
Looping Statements and Control Statements in PythonLooping Statements and Control Statements in Python
Looping Statements and Control Statements in Python
 
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
Python Loops Tutorial | Python For Loop | While Loop Python | Python Training...
 
A Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIOA Prelude of Purity: Scaling Back ZIO
A Prelude of Purity: Scaling Back ZIO
 
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...Sum and Product Types -The Fruit Salad & Fruit Snack Example - From F# to Ha...
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
 
What is Multithreading In Python | Python Multithreading Tutorial | Edureka
What is Multithreading In Python | Python Multithreading Tutorial | EdurekaWhat is Multithreading In Python | Python Multithreading Tutorial | Edureka
What is Multithreading In Python | Python Multithreading Tutorial | Edureka
 
Date and Time Module in Python | Edureka
Date and Time Module in Python | EdurekaDate and Time Module in Python | Edureka
Date and Time Module in Python | Edureka
 
Python for loop
Python for loopPython for loop
Python for loop
 
Lesson 2 derivative of inverse trigonometric functions
Lesson 2 derivative of inverse trigonometric functionsLesson 2 derivative of inverse trigonometric functions
Lesson 2 derivative of inverse trigonometric functions
 
USER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHONUSER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHON
 
Python datetime
Python datetimePython datetime
Python datetime
 
Python Lab manual program for BE First semester (all department
Python Lab manual program for BE First semester (all departmentPython Lab manual program for BE First semester (all department
Python Lab manual program for BE First semester (all department
 
The chain rule
The chain ruleThe chain rule
The chain rule
 
Python programming : Exceptions
Python programming : ExceptionsPython programming : Exceptions
Python programming : Exceptions
 
What is Python Lambda Function? Python Tutorial | Edureka
What is Python Lambda Function? Python Tutorial | EdurekaWhat is Python Lambda Function? Python Tutorial | Edureka
What is Python Lambda Function? Python Tutorial | Edureka
 
Programación Funcional 101 con Scala y ZIO 2.0
Programación Funcional 101 con Scala y ZIO 2.0Programación Funcional 101 con Scala y ZIO 2.0
Programación Funcional 101 con Scala y ZIO 2.0
 

Similar to OPERATOR IN PYTHON-PART2

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
ranaashutosh531pvt
 
Operators inc c language
Operators inc c languageOperators inc c language
Operators inc c language
Tanmay Modi
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
tanmaymodi4
 
Data Handling.pdf
Data Handling.pdfData Handling.pdf
Data Handling.pdf
MILANOP1
 
Introduction to Python
Introduction to Python  Introduction to Python
Introduction to Python
Mohammed Sikander
 
Operators
OperatorsOperators
Operators
loidasacueza
 
Operators
OperatorsOperators
Operators
VijayaLakshmi506
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
savitamhaske
 
1_Python Basics.pdf
1_Python Basics.pdf1_Python Basics.pdf
1_Python Basics.pdf
MaheshGour5
 
Python
PythonPython
Data Handling
Data Handling Data Handling
Data Handling
bharath916489
 
C++ Expressions Notes
C++ Expressions NotesC++ Expressions Notes
C++ Expressions Notes
Prof Ansari
 
C PRESENTATION.pptx
C PRESENTATION.pptxC PRESENTATION.pptx
C PRESENTATION.pptx
VAIBHAV175947
 
python operators.pptx
python operators.pptxpython operators.pptx
python operators.pptx
irsatanoli
 
introduction to c programming and C History.pptx
introduction to c programming and C History.pptxintroduction to c programming and C History.pptx
introduction to c programming and C History.pptx
ManojKhadilkar1
 
power point presentation on topic in C++ called "OPERATORS"
power point presentation on topic in C++ called "OPERATORS"power point presentation on topic in C++ called "OPERATORS"
power point presentation on topic in C++ called "OPERATORS"
sj9399037128
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
Sathish Narayanan
 

Similar to OPERATOR IN PYTHON-PART2 (20)

C – operators and expressions
C – operators and expressionsC – operators and expressions
C – operators and expressions
 
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
 
Data Handling.pdf
Data Handling.pdfData Handling.pdf
Data Handling.pdf
 
Introduction to Python
Introduction to Python  Introduction to Python
Introduction to Python
 
Operators
OperatorsOperators
Operators
 
Operators
OperatorsOperators
Operators
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
 
Java - Operators
Java - OperatorsJava - Operators
Java - Operators
 
Java 2
Java 2Java 2
Java 2
 
1_Python Basics.pdf
1_Python Basics.pdf1_Python Basics.pdf
1_Python Basics.pdf
 
Python
PythonPython
Python
 
Data Handling
Data Handling Data Handling
Data Handling
 
C++ Expressions Notes
C++ Expressions NotesC++ Expressions Notes
C++ Expressions Notes
 
C PRESENTATION.pptx
C PRESENTATION.pptxC PRESENTATION.pptx
C PRESENTATION.pptx
 
python operators.pptx
python operators.pptxpython operators.pptx
python operators.pptx
 
introduction to c programming and C History.pptx
introduction to c programming and C History.pptxintroduction to c programming and C History.pptx
introduction to c programming and C History.pptx
 
power point presentation on topic in C++ called "OPERATORS"
power point presentation on topic in C++ called "OPERATORS"power point presentation on topic in C++ called "OPERATORS"
power point presentation on topic in C++ called "OPERATORS"
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
 

More from vikram mahendra

Communication skill
Communication skillCommunication skill
Communication skill
vikram mahendra
 
Python Project On Cosmetic Shop system
Python Project On Cosmetic Shop systemPython Project On Cosmetic Shop system
Python Project On Cosmetic Shop system
vikram mahendra
 
Python Project on Computer Shop
Python Project on Computer ShopPython Project on Computer Shop
Python Project on Computer Shop
vikram mahendra
 
PYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEMPYTHON PROJECT ON CARSHOP SYSTEM
PYTHON PROJECT ON CARSHOP SYSTEM
vikram mahendra
 
BOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in PythonBOOK SHOP SYSTEM Project in Python
BOOK SHOP SYSTEM Project in Python
vikram mahendra
 
FLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHONFLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHON
vikram mahendra
 
FLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHONFLOWOFCONTROL-IF..ELSE PYTHON
FLOWOFCONTROL-IF..ELSE PYTHON
vikram mahendra
 
FLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHONFLOW OF CONTROL-INTRO PYTHON
FLOW OF CONTROL-INTRO PYTHON
vikram mahendra
 
OPERATOR IN PYTHON-PART1
OPERATOR IN PYTHON-PART1OPERATOR IN PYTHON-PART1
OPERATOR IN PYTHON-PART1
vikram mahendra
 
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
vikram mahendra
 
DATA TYPE IN PYTHON
DATA TYPE IN PYTHONDATA TYPE IN PYTHON
DATA TYPE IN PYTHON
vikram mahendra
 
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
vikram mahendra
 
INTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHONINTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHON
vikram mahendra
 
Python Introduction
Python IntroductionPython Introduction
Python Introduction
vikram mahendra
 
GREEN SKILL[PART-2]
GREEN SKILL[PART-2]GREEN SKILL[PART-2]
GREEN SKILL[PART-2]
vikram mahendra
 
GREEN SKILLS[PART-1]
GREEN SKILLS[PART-1]GREEN SKILLS[PART-1]
GREEN SKILLS[PART-1]
vikram mahendra
 
Dictionary in python
Dictionary in pythonDictionary in python
Dictionary in python
vikram mahendra
 
Entrepreneurial skills
Entrepreneurial skillsEntrepreneurial skills
Entrepreneurial skills
vikram mahendra
 
Boolean logic
Boolean logicBoolean logic
Boolean logic
vikram mahendra
 
Tuple in python
Tuple in pythonTuple in python
Tuple in python
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
 
FLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS IN PYTHONFLOW OF CONTROL-NESTED IFS IN PYTHON
FLOW OF CONTROL-NESTED IFS 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
 
OPERATOR IN PYTHON-PART1
OPERATOR IN PYTHON-PART1OPERATOR IN PYTHON-PART1
OPERATOR IN PYTHON-PART1
 
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
 
DATA TYPE IN PYTHON
DATA TYPE IN PYTHONDATA TYPE IN PYTHON
DATA TYPE IN PYTHON
 
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
USER DEFINE FUNCTIONS IN PYTHON[WITH PARAMETERS]
 
INTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN PYTHONINTRODUCTION TO FUNCTIONS IN PYTHON
INTRODUCTION TO FUNCTIONS IN 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
 

Recently uploaded

How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 

Recently uploaded (20)

How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 

OPERATOR IN PYTHON-PART2

  • 1. CLASS: XI COMPUTER SCIENCE(083) OPERATORS IN PYTHON Comparison operators and Assignment Operators PART-2
  • 2. Assignment Operators Assignment operators are used to assign values to variables: Example: What it does? Shortcut method x=10 x + = 1 # It add 1 to x and assign value to x (left side)x=x+1 print(“x=“,x) x=10 print(“x=“,x) -----OUTPUT----- x= 11 =( equal to)
  • 3. Assignment Operators If you want to subtract the value store inside the variable. Example: What it does? Shortcut method x=10 x - = 1 # It subtract 1 from x and assign value to x (left side)x=x-1 print(“x=“,x) x=10 print(“x=“,x) -----OUTPUT----- x= 9
  • 4. Assignment Operators If you want to multiply(*) the value store inside the variable by 3. Example: What it does? Shortcut method x=10 x * = 3 # It Multiply 3 with x and assign value to x (left side)x=x*3 print(“x=“,x) x=10 print(“x=“,x) -----OUTPUT----- x= 30
  • 5. Assignment Operators If you want to Divide(/ or //) the value store inside the variable by 2. Example: What it does? Shortcut method x=10 x / = 2# It x or y divide by 2 and assign value to x or y (left side) x=x/2 print(“x=“,x) x=10 print(“x=“,x)-----OUTPUT----- x= 5.0 y=5 y // = 2y=y//2 print(“y=“,y) print(“y=“,y) y=10 y=10
  • 6. Assignment Operators If you want Modulus(%) of the value. Example: Shortcut method x=10 x % = 3x=x%3 print(“x=“,x) x=10 print(“x=“,x) -----OUTPUT----- x= 1 If you want Exponential(**) of the value. Example: Shortcut method x=3 x ** = 2x=x**2 print(“x=“,x) x=3 print(“x=“,x) -----OUTPUT----- x= 9
  • 7. Relational or Comparison Operators Comparison operators are used to compare two values. Comparison operators are used to comparing the value of the two operands and returns Boolean true or false Operator: Description == != If the value of two operands is equal, then the condition becomes true. If the value of two operands is not equal, then the condition becomes true. < Example: If the first operand is less than the second operand, then the condition becomes true. <= If the first operand is less than or equal to the second operand, then the condition becomes true > If the first operand is greater than the second operand, then the condition becomes true. >= If the first operand is greater than or equal to the second operand, then the condition becomes true. X==Y X!=Y X<Y X<=Y X>Y X>=Y
  • 8. Relational or Comparison Operators Program to check all the relational operator working in python. x=10 y=20 print(“x==y:”,x==y) print(“x!=y:”,x!=y) print(“x<y:”,x<y) print(“x<=y:”,x<=y) print(“x>y:”,x>y) print(“x>=y:”,x>=y) -----OUTPUT----- x==y: False x!=y: True x<y: True x<=y: True x>y: False x>=y: False
  • 9. Logical Operators Logical operators are used to combine conditional statements: and or not Returns True if both statements are true Returns True if one of the statements is true Reverse the result, returns False if the result is true A B A and B T T T T F F F T F F F F A B A OR B T T T T F T F T T F F F A NOT A T F F T
  • 10. Logical Operators x=40 y=20 z=5 print(x>y and x==z) and or not x=40 y=20 z=5 print(x>y or x==z) x=40 y=20 print(not (x>y)) --Output---- False --Output---- True --Output---- False
  • 11. Logical Operators Write the output of the expression given below: A=10 , B=5 , C=3 , D=-5 ((A>B) OR (B!=C)) AND (NOT(A!=C) AND (C>B)) ((10>5) OR (5!=3)) AND (NOT(10!=3) AND (3>5)) ((T) OR (T)) AND (NOT(T) AND (F)) (TRUE) AND (FALSE AND FALSE) (TRUE) AND (FALSE) FALSE
  • 12. Identity Operators Identity Operators in Python are used to compare the memory location of two objects. Identity operator (“is” and “is not”) is used to compare the object’s memory location. When an object is created in memory a unique memory address is allocated to that object. is is not It returns true if two variables point the same object and false otherwise It returns false if two variables point the same object and true otherwise
  • 13. is operator: x = 5 print(type(x) is int) --Output---- True x = 5 print(type(x) is float) Output: False is not operator: x = 5 print(type(x) is not int) --Output---- False x = 5 print(type(x) is not float) Output: True
  • 14. Example: If we declare three variable to store name “Mohit”,”Rohit”,and again “Mohit”, then use == operator of check these names equality. nm1=‘Mohit’ nm2=‘Rohit’ nm3=‘Mohit’ print(nm1==nm2) print(nm2==nm3) print(nm1==nm2) Comparison operator “==” to check if both the object values are the same. ----Output----- False False True
  • 15. Example: If we declare two variable a, b and store same number 10 and then use is or is not identity operator. a=10 b=10 print(a is b) ----Output----- True a=10 b=20 print(a is b) ----Output----- False
  • 16. Example: If we declare three variable to store name “Mohit”,”Rohit”,and again “Mohit”, They are usually used to determine the type of data a certain variable contains. nm1=‘Mohit’ nm2=‘Rohit’ nm3=‘Mohit’ print(nm1 is nm2) print(nm2 is nm3) print(nm1 is nm2) ----Output----- False False True print(nm1 is not nm2) print(nm2 is not nm3) print(nm1 is not nm2) ----Output----- True True False
  • 17. Example: If we declare three variable to store name “Mohit”,”Rohit”,and again “Mohit”, They are usually used to determine the type of data a certain variable contains. nm1=‘Mohit’ nm2=‘Rohit’ nm3=‘Mohit’ The built-in id() a function is used to get the “identity” of an object. print(“nm1 memory address:”,id(nm1)) print(“nm2 memory address:”,id(nm2)) print(“nm3 memory address:”,id(nm3)) ----Output----- nm1 memory address :45891616 nm2 memory address :45891648 nm3 memory address :45891616 So that is why nm1 is nm3 show : True And nm1 is nm2 show : False
  • 18. Now let Us understand that why nm1 and nm3 memory address are same and nm2 is different. Memory Mohit Rohit nm1 nm2 nm3 nm1=‘Mohit’ nm2=‘Rohit’ nm3=‘Mohit’ Instead of creating a separate object nm3 ,It will act as a pointer pointing to nm1 which hold the same value create create
  • 19. Membership Operators Python’s membership operators test for membership in a sequence, such as strings, lists, or tuples. in not in Evaluates to true if it finds a variable in the specified sequence and false otherwise. Evaluates to true if it does not finds a variable in the specified sequence and false otherwise
  • 20. x = 'Hello world' Membership Operators in operator: Let us understand the in operator with the help of example print('H' in x) --Output-- True print(‘hello' in x) True print(‘World' in x) False