top of page

Python Operators

Python supports different types of operators, which is like that –

  • Arithmetic operators

  • Assignment operators

  • Comparison operators

  • Logical operators

  • Identity operators

  • Membership operators

  • Bitwise operators

Arithmetic operators

These are used with a numeric value to calculate mathematical calculations.

Here some arithmetic operators which used in python mathematical calculations.

+(addition), -(subtraction), *(multiplication), /(division), etc.

 

How we can use it?

Anyone can we use it using simple syntax -

>>> a = 5

>>> b = 6

>>> c = a+b

>>> print(c)

Assignment Operator

Python support large number of assignment Operator here we choose-

=, +=, -=, *=, /=, etc

Example:

x = "hi"

print(x)

Comparison Operators

It is used to compare two variables

Here list of comparison variables are –

==, >=, <=, >, <, !=, etc

 

Example:

Output: True

x = 2
y = 2

print(x == y)

Logical Operators

Logical Operator basically performs upon the conditional operator, here some logical operator which used in python.

and, or, not

Output: True

x = 9

print(x > 2 and x < 11)

And Many other operators, like bitwise operators, etc. which used to perform upon python.

I hope it may be helpful to work with python operators, in the next tutorial we will learn how to implement lists in python

bottom of page