Floor Division Operator
Python Floor Division Operator takes two operands, one on the left and other on the right, and returns the floor (rounded to the lower ceiling point) of the quotient of the division operation.
The symbol used for Python Floor Division operator is
Following is the syntax of Floor Division Operator in Python.
result = operand_1 // operand_2
operand_2 are numbers and the result is the floor of the quotient when
operand_1 is divided by
Example 1: Floor Division of Integers
In this example, we shall take two integers, divide them, find the integer quotient that is rounded to the lower ceiling integer, and print the result.
a = 14 b = 5 result = a // b print('Quotient :', result)
Quotient : 2
Now, let us take negative numbers and find the floor of the quotient when we do division with these negative numbers.
a = -11 b = 5 result = a // b print('Quotient :', result)
Quotient : -3
-11/5 is -2.2. Floor of -2.2 is -3.
Example 2: Floor Division of Floating Point Numbers
We can compute the floor division of floating point numbers. In the following example, we initialize two floating point numbers, and find the floor of the quotient resulting from the division of these two numbers.
a = 14.8 b = 5.1 result = a // b print('Quotient :', result)
Quotient : 2.0
In this tutorial of Python Examples, we learned what Python Floor Division Operator is, how to use it to find the floor of the quotient in the division of given two numbers.