study guides for every class

that actually explain what's on your next test

Floor division

from class:

Intro to Python Programming

Definition

Floor division is an operation that divides two numbers and returns the largest integer less than or equal to the result. In Python, it is performed using the // operator.

congrats on reading the definition of Floor division. now let's actually learn it.

ok, let's learn stuff

5 Must Know Facts For Your Next Test

  1. The floor division operator in Python is //.
  2. Floor division always rounds down to the nearest whole number.
  3. When both operands are integers, the result of floor division is an integer.
  4. When at least one operand is a float, the result of floor division is a float.
  5. Floor division can be used with both positive and negative numbers, following the rule of rounding towards minus infinity.

Review Questions

  • What operator is used for floor division in Python?
  • How does floor division handle the result when dividing two numbers?
  • What type of value (integer or float) does floor division return when one of the operands is a float?

"Floor division" also found in:

© 2024 Fiveable Inc. All rights reserved.
AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.