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 '//'.
🌐
LearnDataSci
learndatasci.com › solutions › python-double-slash-operator-floor-division
Python Double Slash (//) Operator: Floor Division – LearnDataSci
In Python, we can perform floor division (also sometimes known as integer division) using the // operator.
People also ask

What Does Floor Mean in Python?
In Pythonfloor’ 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
Answer (1 of 13): It’s function is pretty obvious when you compare it to floating point division (‘/’). Let’s look at an example: 3 / 2 = 1.5 # Floating point division 3 // 2 = 1 # Floor division (AKA Integer division) As you can see, “Floor division” returns the “floor” of ...
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.

🌐
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.org
discuss.python.org › python help
Integer division - Python Help - Discussions on Python.org
January 25, 2023 - There is no “integer division” in Python. We have floor division which does division, keeping the floor of the result.
🌐
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”).
🌐
CodeGym
codegym.cc › java blog › learning python › floor division in python
Floor Division in Python
November 11, 2024 - In this article, we’ll break down ... Let’s get started! In Python, floor division is an operation that divides two numbers and rounds down the result to the nearest integer....