Ticker

6/recent/ticker-posts

Python Operators

 Python Operators

Python Operators

Generally, operators are used to performing a certain operation in our programming application,

Python supports many operators, in this article we see detailed notes about python operators. Let's get started!

Python divided operators into the following types:

  • Arithmetic operators
  • Assignment operators
  • Comparison operators
  • Logical operators
  • Identity operator
  • Membership operators
  • Bitwise operators

python arithmetic operators

Arithmetic operators are used with numeric values to perform common mathematical operations:

Operator Name Example
Operator+ NameAddition Examplex+y
Operator- NameSubtraction Examplex-y
Operator* Namemultiplication Examplex*y
Operator/ NameDivision Examplex/y
Operator% NameModulus Examplex%y
Operator** NameExponentiation Examplex**y
Operator// NameFloor Division Examplex//y


Python Assignment Operators

Assignment operators are used to assign values to variables:

Operator Example Same As
Operator= Examplex=3 Same Asx=3
Operator+= Examplex+=2 Same Asx=x+2
Operator-= Examplex-=2 Same Asx=x-2
Operator*= Examplex*=2 Same Asx=x*2
Operator/= Examplex=/2 Same Asx=x/2
Operator** Examplex**=2 Same Asx=x**2


Python Comparison Operators:

These operators are used to compare two values:

Operator Name Example
Operator= NameEqual Examplex==y
Operator!= NameNot Equal Examplex!=y
Operator> NameGreater Than Examplex>y
Operator< NameLess Than ExampleX
Operator>= NameGreator than or equal to Examplex>=y
Operator<= NameLess than or equal to Examplex<=y


Python Logic Operators

This type of operator is used to combine two conditional statements:

Operator Name Example
Operator= NameEqual Examplex==y
Operator!= NameNot Equal Examplex!=y
Operator> NameGreater Than Examplex>y
Operator< NameLess Than ExampleX
Operator>= NameGreator than or equal to Examplex>=y
Operator<= NameLess than or equal to Examplex<=y


Post a Comment

0 Comments