What is the purpose of the `//` operator in python?


In Python, // is defined as floor division operator. It returns integer part of a floating point result of division. For example 10//3 returns 3

>>> 10//3
3
>>> 125.5//2.5
50.0
>>> 12.5//1.5
8.0

However in case of negative division, returned value is rounded towards negative infinity.

>>> -10//3
-4
>>> -73//9
-9

Updated on: 26-Feb-2020

241 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements