In Python 3.x, 5 / 2 will return 2.5 and 5 // 2 will return 2. The former is floating point division, and the latter is floor division, sometimes also called integer division.

In Python 2.2 or later in the 2.x line, there is no difference for integers unless you perform a from __future__ import division, which causes Python 2.x to adopt the 3.x behavior.

Regardless of the future import, 5.0 // 2 will return 2.0 since that's the floor division result of the operation.

You can find a detailed description at PEP 238: Changing the Division Operator.

Answer from Eli Courtwright on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ floor-division-in-python
Floor Division in Python - GeeksforGeeks
July 23, 2025 - Floor division is a division operation that returns the largest integer that is less than or equal to the result of the division. In Python, it is denoted by the double forward slash '//'.
People also ask

What Does Floor Mean in Python?
In Python โ€˜floorโ€™ refers to rounding a number down to the nearest integer, disregarding the fractional part. This can be done using the math.floor() function or using the โ€˜//โ€™ operator. For instance, math.floor (4.7) or 4.7 // 1 would return 4. It is important in all calculations requiring integer values.
๐ŸŒ
theknowledgeacademy.com
theknowledgeacademy.com โ€บ blog โ€บ floor-division-in-python
Floor Division in Python: Everything You Need to Know
Why Would You Use Floor Division?
Floor Division is used when only the whole number portion of a division is required, ignoring the remainder. Examples include evenly dividing items (e.g., oranges), calculating integer averages, or converting seconds to minutes.
๐ŸŒ
theknowledgeacademy.com
theknowledgeacademy.com โ€บ blog โ€บ floor-division-in-python
Floor Division in Python: Everything You Need to Know
What are the Related Courses and Blogs Provided by The Knowledge Academy?
The Knowledge Academy offers various Programming Training, including the Python Course, PHP Course and the Vue.js Framework Training. These courses cater to different skill levels, providing comprehensive insights into Python Enumerate. Our Programming and DevOps cover a range of topics related to Python, offering valuable resources, best practices, and industry insights. Whether you are a beginner or looking to advance your Programming Skills, The Knowledge Academy's diverse courses and informative blogs have got you covered.
๐ŸŒ
theknowledgeacademy.com
theknowledgeacademy.com โ€บ blog โ€บ floor-division-in-python
Floor Division in Python: Everything You Need to Know
๐ŸŒ
Mimo
mimo.org โ€บ glossary โ€บ python โ€บ floor-division
Python Floor Division: Syntax, Usage, and Examples
Understanding the difference between the standard division (/) and the Python double slash operator is essential. Here's a comparison: ... The standard division always returns a float, while floor division truncates the decimal part.
๐ŸŒ
The Knowledge Academy
theknowledgeacademy.com โ€บ blog โ€บ floor-division-in-python
Floor Division in Python: Everything You Need to Know
February 5, 2026 - Wondering how Floor Division in Python works? Itโ€™s a mathematical operation that divides two numbers and rounds down to the nearest whole number. This blog explains the concept with examples, covering its syntax, use cases, and tips to use it effectively in Python programming.
Find elsewhere
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_operators_arithmetic.asp
Python Arithmetic Operators
Python has two division operators: / - Division (returns a float) // - Floor division (returns an integer) Division always returns a float: x = 12 y = 5 print(x / y) Try it Yourself ยป ยท Floor division always returns an integer.
๐ŸŒ
Quora
quora.com โ€บ What-does-floor-division-in-Python-do
What does floor division ('//') in Python do? - Quora
Python (programming langu... ... Computer Science and Prog... ... Floor division in Python (operator //) divides two numbers and returns the mathematical floor of the quotient โ€” the largest integer less than or equal to the true quotient.
๐ŸŒ
YouTube
youtube.com โ€บ watch
Python Under 5 Minutes: Floor Division - YouTube
In this video, we will go over floor division in Python. We will look at how division is handled in Python and how we can handle just getting a whole number...
Published ย  September 8, 2023
Top answer
1 of 3
29

Use this. this will help you.

a,b = divmod(10,2)

it will return both value

2 of 3
12

There is a significant difference in performance if you use larger numbers.

Here is an example using both small and large numbers:

$ py27 -m timeit -s "a=123;b=7" "divmod(a,b)"
10000000 loops, best of 3: 0.0913 usec per loop
$ py27 -m timeit -s "a=123;b=7" "a//b;a%b"
10000000 loops, best of 3: 0.047 usec per loop
$ py27 -m timeit -s "a=123333333333333333333333333333333333333;b=7222222222222222222" "divmod(a,b)"
10000000 loops, best of 3: 0.165 usec per loop
$ py27 -m timeit -s "a=123333333333333333333333333333333333333;b=7222222222222222222" "a//b;a%b"
1000000 loops, best of 3: 0.232 usec per loop

Why the difference?

divmod() requires a function call while // and % are operators. There is additional overhead for a function call relative to operators. So when the cost of the computation is minimal, the overhead of calling a function is much greater than the actual cost of the calculation(s).

For larger numbers, divmod() is faster. divmod() calculates both the quotient and remainder at the same time and returns both of them. The // and % operators each calculate the quotient and remainder but only return one of the results.

divmod() has more overhead but only performs one division. // and % have less overhead but perform two divisions. As long as the overhead is large compared to time to perform division, divmod() will be slower. But once the cost of a division is greater than the overhead, divmod() will be faster.

๐ŸŒ
Python.org
discuss.python.org โ€บ python help
Integer division - Python Help - Discussions on Python.org
January 25, 2023 - What is the result of this code: print(6 // 0.4) I thought the answer is 15.0 but I am getting 14.0. Any explanation for this answer I will appreciate.
๐ŸŒ
NxtWave
ccbp.in โ€บ blog โ€บ articles โ€บ floor-division-in-python
Floor Division in Python: Explained with Examples
April 30, 2025 - Floor Division in Python is a mathematical operation in Python that divides two numbers and rounds the result down to the nearest whole number (integer or float, depending on the operands).
๐ŸŒ
OpenStax
openstax.org โ€บ books โ€บ introduction-python-programming โ€บ pages โ€บ 2-5-dividing-integers
2.5 Dividing integers - Introduction to Python Programming | OpenStax
March 13, 2024 - Ex: 7 / 4 becomes 7.0 / 4.0, resulting in 1.75. Floor division (//) computes the quotient, or the number of times divided. Ex: 7 // 4 is 1 because 4 goes into 7 one time, remainder 3. The modulo operator (%) computes the remainder.
๐ŸŒ
The Teclado Blog
blog.teclado.com โ€บ pythons-modulo-operator-and-floor-division
Python's modulo operator and floor division
October 26, 2022 - The amount left over after the ... to carry out Euclidean division, but unlike the modulo operator, floor division yields the quotient, not the remainder....
๐ŸŒ
Metaschool
metaschool.so โ€บ home โ€บ answers โ€บ what is floor division in python? guide with examples
What is Floor Division in Python? Guide With Examples
December 6, 2024 - In Python, floor division is a powerful operator that allows you to divide two numbers and return the largest integer less than or equal to the result. Unlike regular division, which can produce a floating-point number, floor division simplifies ...
๐ŸŒ
Python
peps.python.org โ€บ pep-0238
PEP 238 โ€“ Changing the Division Operator | peps.python.org
We propose to fix this by introducing different operators for different operations: x/y to return a reasonable approximation of the mathematical result of the division (โ€œtrue divisionโ€), x//y to return the floor (โ€œfloor divisionโ€).