Sitemap
Mayuresh shewale

Mayuresh shewale

Data Analyst student

Python Operators

2 min readMar 1, 2022

--

Operators are special symbols in Python that carry out arithmetic or logical computation.

Press enter or click to view image in full size
Operators in python

[1] Arithmetic operators

x = 15
y = 4

1) Add +

# Output: x + y = 19
print(‘x + y =’,x+y)

2) Subtract -

# Output: x -y = 11
print(‘x-y =’,x-y)

3) Multiply *

# Output: x * y = 60
print(‘x * y =’,x*y)

4) Divide /

# Output: x / y = 3.75
print(‘x / y =’,x/y)

5) Floor division //

# Output: x // y = 3
print(‘x // y =’,x//y)

6) Exponent left operand raised to the power of right **

# Output: x ** y = 50625
print(‘x ** y =’,x**y)

[2] Comparison operators

x = 10
y = 12

1) >

# Output: x > y is False
print(‘x > y is’, x>y)

2) <

# Output: x < y is True
print(‘x < y is’, x<y)

3) ==

# Output: x == y is False
print(‘x == y is’, x==y)

4) !=

# Output: x != y is True
print(‘x != y is’, x!=y)

5) ≥

# Output: x >= y is False
print(‘x >= y is’, x>=y)

6) ≤

# Output: x <= y is True
print(‘x <= y is’, x<=y)

[3] Logical operators

x = True
y = False

1) and

print(‘x and y is’,x and y)

Get Mayuresh shewale’s stories in your inbox

Join Medium for free to get updates from this writer.

x and y is false

2) or

print(‘x or y is’,x or y)

x or y is True

3) not

print(‘not x is’,not x)

not x is false

[4] Bitwise operators

1) &Bitwise AND

2) Bitwise OR

3) Bitwise NOT

4) Bitwise XOR

5) >>Bitwise right shift

6) <<Bitwise left shift

[5] Assignment operators

  1. =
  2. +=
  3. -=
  4. *=
  5. /=
  6. %=
  7. //=
  8. **=
  9. &=
  10. |=
  11. ^=
  12. >≥
  13. <≤

[6] Identity operators

is and is not are the identity operators in Python.

[7] Membership operators

in and not in are the membership operators in Python.

--

--