SlideShare a Scribd company logo
2
Most read
3
Most read
OPERATORS
Problem Solving and Python Programming 2
‡ An operator is a symbol that represents an
operations that may be performed on one or
more operands.
‡ An operand is a value that a given operator is
applied to.
‡ Example: 4+(3*k)
+, * are operator and 4,3,k are operands
Different forms of operator
‡ Unary Operator:
± Unary arithmetic operators perform mathematical operations on
RQHRSHUDQGRQO7KHµ¶DQGµ-µ¶are two unary operators.
± Example:
 x = -5 #Negates the value of X
 x
-5
‡ Binary operator:
± A Binary operator operates on two operands
± Example:
 3 + 10
13
 10 ± 7
 3
Problem Solving and Python Programming 3
Types of Operators
1. Arithmetic operator
2. Relational operator
3. Logical operator
4. Bitwise operator
5. Assignment operator
6. Special operator
Problem Solving and Python Programming 4
1. Arithmetic operator
‡ Arithmetic operators are basic mathematical
operations.
Problem Solving and Python Programming 5
Operator Meaning Example Result
+ Addition C=12+1 C=13
- Subtraction C=12-1 C=11
* Multiplication C=12*1 C=12
/ Division C=12/1 C=12
// Floor division C=12//10 1
% Modulus C=12%10 C=2
** Exponentiation C=10**2 C=100
Example of Arithmetic Operator
print(Arithmetic Operator)
a=10
b=5
print(Addition:,a+b)
print(Subtraction:,a-b)
print(Multiplication:,a*b)
print(Division:,a/b)
print(Floor Division:,a//b)
print(Modulus:,a%b)
print(Exponent,a**b)
Problem Solving and Python Programming 6
Output:
2. Relational operator
‡ Relational operators are also called as Comparison
operators
‡ It is used to compare values.
‡ It either returns True or False according to condition.
Problem Solving and Python Programming 7
Operator Meaning Example Result
 Greater than 56 False
 Less than 56 True
== Equal to 5==6 False
!= Not equal to 5!=6 True
= Greater than or equal to 5=6 False
= Less than or equal to 5=6 True
Example of Relational Operator
print(Relational Operator)
a=10
b=5
print(ab)
print(ab)
print(a==b)
print(a!=b)
print(a=b)
print(a=b)
Problem Solving and Python Programming 8
Output:
3. Logical operator
Problem Solving and Python Programming 9
‡ Logical operator are typically used with
Boolean(logical) values.
‡ They allow a program to make a decision
based on multiple condition.
Operator Meaning Example Result
and True if both the
operands are true
105 and 1020 False
or True if either of the
operands is true
105 or 1020 True
not True if operands is
false ( complements
the operand)
not (1020) False
Example of Logical Operator
print(Logical Operator)
print(105 and 1020)
print(105 or 1020)
print(not(1020))
Problem Solving and Python Programming 10
Logical Operator
False
True
False
Output:
4. Bitwise operator
‡ Bitwise operators act on operands as if they are
string of binary digits.
‡ It operates bit by bit.
Problem Solving and Python Programming 11
Operator Meaning Example
 Bitwise AND a  b
| Bitwise OR a | b
~ Bitwise NOT a ~ b
^ Bitwise XOR a ^ b
 Bitwise right shift a  2
 Bitwise left shift a  2
5. Assignment operator
‡ Assignment operators are used to assign values
to variables.
Problem Solving and Python Programming 12
Operator Meaning Example
= Assign a value a=5
+= Adds and assign the result to the variable a+=1 (a=a+1)
-= Subtracts and assign the result to the variable a-=1 (a=a-1)
*= Multiplies and assign the result to the variable a*=5 (a=a*5)
/= Division and assign the result to the variable a/= (a=a/5)
//= Floor division and assign the result to the variable a//=5(a=a//5)
%= Find modulus and assign the result to the variable a%=5 (a=a%5)
**= Find Exponentiation and assign the result to the
variable
a**=5 (a=a**5)
Problem Solving and Python Programming 13
Operator Meaning Example
= Find Bitwise AND and assign the result to the variable a=5(a=a5)
|= Find Bitwise OR and assign the result to the variable a|=5(a=a|5)
^= Find Bitwise XOR and assign the result to the variable a^=5(a=a^5)
= Find Bitwise right shift and assign the result to the
variable
a=5 (a=a5)
= Find Bitwise left shift and assign the result to the
variable
a=5 (a=a5)
6. Special operator
‡ Python offers some special operators like
identity operator and the membership operator.
‡ Identity Operator:
± is and is not are the identity operator
Problem Solving and Python Programming 14
Operator Meaning Example
is True if the operands
are identical
a is true
is not True if the operands
are not identical
a is not true
Example of Identity Operator
a1=5
b1=5
a2=Hello
b2=Hello
a3=[1,2,3]
b3=[1,2,3]
print(a1 is not b1)
print(a2 is b2)
print(a2 is b3)
Problem Solving and Python Programming 15
Output:
False
True
False
‡ Membership Operators:
± in and not in are the membership operators.
Problem Solving and Python Programming 16
Operator Meaning Example
in True if value/
variable is found in
the sequence
5 in a
not in True if value/
variable is not
found in the
sequence
5 not in a
Example of Membership Operator
a=Hello world
b={1,a,b,2}
print(H in a)
print(hello in a )
print(1 in b)
print(b in b)
3ULQW ³F´QRWLQE
Problem Solving and Python Programming 17
Output:
True
False
True
True
True

More Related Content

PDF
Operators in python
PPTX
operatorsinpython-18112209560412 (1).pptx
PPTX
Understanding All Types of Operators in Python with Examples"
PPTX
Python Operators
PPTX
Python Programming | JNTUK | UNIT 1 | Lecture 5
PPTX
Operators in Python Arithmetic Operators
PPTX
Operators Concept in Python-N.Kavitha.pptx
PPTX
Different Types of Operators in Python.pptx
Operators in python
operatorsinpython-18112209560412 (1).pptx
Understanding All Types of Operators in Python with Examples"
Python Operators
Python Programming | JNTUK | UNIT 1 | Lecture 5
Operators in Python Arithmetic Operators
Operators Concept in Python-N.Kavitha.pptx
Different Types of Operators in Python.pptx

Similar to Operators_in_Python_Simplified_languages (20)

PPTX
Operators in Python
PPTX
Python Lec-6 Operatorguijjjjuugggggs.pptx
PPTX
Python programming language introduction unit
PPTX
PYTHON OPERATORS 123Python Operators.pptx
PPTX
python operators.pptx
PPTX
Python operators
PPTX
Operators-----------------in-Python.pptx
PPTX
python statement, expressions and operators.pptx
PPTX
OPERATORS-PYTHON.pptx ALL OPERATORS ARITHMATIC AND LOGICAL
PPTX
Python operators
PPTX
Operators in python
PPT
Py-Slides-2 (1).ppt
PPT
Py-Slides-2.ppt
PPT
Py-Slides-2.ppt
PPT
hlukj6;lukm,t.mnjhgjukryopkiu;lyk y2.ppt
PPTX
Second session from learn python tutorial
PDF
Python : basic operators
PDF
Python (high level programming ) language
PDF
Python basic operators
Operators in Python
Python Lec-6 Operatorguijjjjuugggggs.pptx
Python programming language introduction unit
PYTHON OPERATORS 123Python Operators.pptx
python operators.pptx
Python operators
Operators-----------------in-Python.pptx
python statement, expressions and operators.pptx
OPERATORS-PYTHON.pptx ALL OPERATORS ARITHMATIC AND LOGICAL
Python operators
Operators in python
Py-Slides-2 (1).ppt
Py-Slides-2.ppt
Py-Slides-2.ppt
hlukj6;lukm,t.mnjhgjukryopkiu;lyk y2.ppt
Second session from learn python tutorial
Python : basic operators
Python (high level programming ) language
Python basic operators
Ad

Recently uploaded (20)

PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
additive manufacturing of ss316l using mig welding
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
Geodesy 1.pptx...............................................
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
Safety Seminar civil to be ensured for safe working.
PPT
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPT
introduction to datamining and warehousing
PDF
composite construction of structures.pdf
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Lecture Notes Electrical Wiring System Components
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
bas. eng. economics group 4 presentation 1.pptx
Embodied AI: Ushering in the Next Era of Intelligent Systems
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Automation-in-Manufacturing-Chapter-Introduction.pdf
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
additive manufacturing of ss316l using mig welding
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
R24 SURVEYING LAB MANUAL for civil enggi
Geodesy 1.pptx...............................................
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Safety Seminar civil to be ensured for safe working.
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
introduction to datamining and warehousing
composite construction of structures.pdf
Ad

Operators_in_Python_Simplified_languages

  • 1. OPERATORS Problem Solving and Python Programming 2 ‡ An operator is a symbol that represents an operations that may be performed on one or more operands. ‡ An operand is a value that a given operator is applied to. ‡ Example: 4+(3*k) +, * are operator and 4,3,k are operands
  • 2. Different forms of operator ‡ Unary Operator: ± Unary arithmetic operators perform mathematical operations on RQHRSHUDQGRQO7KHµ¶DQGµ-µ¶are two unary operators. ± Example: x = -5 #Negates the value of X x -5 ‡ Binary operator: ± A Binary operator operates on two operands ± Example: 3 + 10 13 10 ± 7 3 Problem Solving and Python Programming 3
  • 3. Types of Operators 1. Arithmetic operator 2. Relational operator 3. Logical operator 4. Bitwise operator 5. Assignment operator 6. Special operator Problem Solving and Python Programming 4
  • 4. 1. Arithmetic operator ‡ Arithmetic operators are basic mathematical operations. Problem Solving and Python Programming 5 Operator Meaning Example Result + Addition C=12+1 C=13 - Subtraction C=12-1 C=11 * Multiplication C=12*1 C=12 / Division C=12/1 C=12 // Floor division C=12//10 1 % Modulus C=12%10 C=2 ** Exponentiation C=10**2 C=100
  • 5. Example of Arithmetic Operator print(Arithmetic Operator) a=10 b=5 print(Addition:,a+b) print(Subtraction:,a-b) print(Multiplication:,a*b) print(Division:,a/b) print(Floor Division:,a//b) print(Modulus:,a%b) print(Exponent,a**b) Problem Solving and Python Programming 6 Output:
  • 6. 2. Relational operator ‡ Relational operators are also called as Comparison operators ‡ It is used to compare values. ‡ It either returns True or False according to condition. Problem Solving and Python Programming 7 Operator Meaning Example Result Greater than 56 False Less than 56 True == Equal to 5==6 False != Not equal to 5!=6 True = Greater than or equal to 5=6 False = Less than or equal to 5=6 True
  • 7. Example of Relational Operator print(Relational Operator) a=10 b=5 print(ab) print(ab) print(a==b) print(a!=b) print(a=b) print(a=b) Problem Solving and Python Programming 8 Output:
  • 8. 3. Logical operator Problem Solving and Python Programming 9 ‡ Logical operator are typically used with Boolean(logical) values. ‡ They allow a program to make a decision based on multiple condition. Operator Meaning Example Result and True if both the operands are true 105 and 1020 False or True if either of the operands is true 105 or 1020 True not True if operands is false ( complements the operand) not (1020) False
  • 9. Example of Logical Operator print(Logical Operator) print(105 and 1020) print(105 or 1020) print(not(1020)) Problem Solving and Python Programming 10 Logical Operator False True False Output:
  • 10. 4. Bitwise operator ‡ Bitwise operators act on operands as if they are string of binary digits. ‡ It operates bit by bit. Problem Solving and Python Programming 11 Operator Meaning Example Bitwise AND a b | Bitwise OR a | b ~ Bitwise NOT a ~ b ^ Bitwise XOR a ^ b Bitwise right shift a 2 Bitwise left shift a 2
  • 11. 5. Assignment operator ‡ Assignment operators are used to assign values to variables. Problem Solving and Python Programming 12 Operator Meaning Example = Assign a value a=5 += Adds and assign the result to the variable a+=1 (a=a+1) -= Subtracts and assign the result to the variable a-=1 (a=a-1) *= Multiplies and assign the result to the variable a*=5 (a=a*5) /= Division and assign the result to the variable a/= (a=a/5) //= Floor division and assign the result to the variable a//=5(a=a//5) %= Find modulus and assign the result to the variable a%=5 (a=a%5) **= Find Exponentiation and assign the result to the variable a**=5 (a=a**5)
  • 12. Problem Solving and Python Programming 13 Operator Meaning Example = Find Bitwise AND and assign the result to the variable a=5(a=a5) |= Find Bitwise OR and assign the result to the variable a|=5(a=a|5) ^= Find Bitwise XOR and assign the result to the variable a^=5(a=a^5) = Find Bitwise right shift and assign the result to the variable a=5 (a=a5) = Find Bitwise left shift and assign the result to the variable a=5 (a=a5)
  • 13. 6. Special operator ‡ Python offers some special operators like identity operator and the membership operator. ‡ Identity Operator: ± is and is not are the identity operator Problem Solving and Python Programming 14 Operator Meaning Example is True if the operands are identical a is true is not True if the operands are not identical a is not true
  • 14. Example of Identity Operator a1=5 b1=5 a2=Hello b2=Hello a3=[1,2,3] b3=[1,2,3] print(a1 is not b1) print(a2 is b2) print(a2 is b3) Problem Solving and Python Programming 15 Output: False True False
  • 15. ‡ Membership Operators: ± in and not in are the membership operators. Problem Solving and Python Programming 16 Operator Meaning Example in True if value/ variable is found in the sequence 5 in a not in True if value/ variable is not found in the sequence 5 not in a
  • 16. Example of Membership Operator a=Hello world b={1,a,b,2} print(H in a) print(hello in a ) print(1 in b) print(b in b) 3ULQW ³F´QRWLQE Problem Solving and Python Programming 17 Output: True False True True True