Python float division: How to Divide Float Values in Python

Python float division - How to Divide Float Values in Python

Python has two kinds of division: integer division and float division. Integer division returns the floor of the division. Integer values are precisely stored, so they are safe to use in comparisons. In this example, we will look at how to perform float division.

Python float division

To divide float values in Python, use the / operator. The Division operator / takes two parameters and returns the float division. Float division produces a floating-point conjecture of the result of a division.

If you are working with Python 3 and you need to perform a float division, then use the division operator.

print(10 / 9)



Only a specific number of values after the decimal can be saved, so it is not possible to store an exact binary description of many floating-point numbers.

Float division for Python 2

In Python 2, the only standard division operator is “/”. If both values are integers, the result is an integer. If either of the values is the float, the return is the float value.

To perform float division in Python 2, import the division package __future__ module and then use the “\\” operator to get the result.

from __future__ import division

print(10 // 9)



In Python 3, the single slash (/) means proper division. The // operator is used for truncating division. Adding a dot (.) operator indicates the floating-point numbers.

That’s it for this tutorial.

Leave A Reply

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.