Skip to content

Division Operators in Python

  • by

Python has two types of division operators. Both allow you to divide two numbers and return a quotient, i.e., the first number (number at the left) is divided by the second number (number at the right) and returns the quotient.

  • /: Divides the number and returns a floating point value.
  • //: Divides the number and returns a whole number (round down).

Division Operators in Python

Simple example code.

# Dividing an integer by an integer
print("The answer for 5/2: ", 5 / 2)
print("The answer for 5//2: ", 5 // 2)

# Dividing an integer by a float
print("The answer for 5/2.75: ", 5 / 2.75)
print("The answer for 5//2.75: ", 5 // 2.75)

# Dividing a float by an integer
print("The answer for 5.5/2: ", 5.5 / 2)
print("The answer for 5.5//2: ", 5.5 // 2)

# Dividing a float by an float
print("The answer for 5.5/2.5: ", 5.5 / 2.5)
print("The answer for 5.5//2.5: ", 5.5 // 2.5)

Output:

Division Operators in Python

Do comment if you have any doubts or suggestions on this Python Operator topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Your email address will not be published. Required fields are marked *