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: 2020-02-26T10:55:31+05:30

512 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements