0
in the float lesson it for division a single forward slash was used but in numeric operators it uses 2 forward slashes why??
2 Respuestas
+ 2
The two forward slashes means that it divides the first operand by the second, and then rounds down. So 7 // 3 = 2.
+ 2
They are unlike operators.
/ - performs float division, that is, if you use it with two integers, the result always will be an float. The result shows its decimal part.
For other hand, // operator, only returns the integer division part discarding the decimal part.
An example:
>>> 5/2
2.5
>>>4/2
2.0
>>>5//2
2
>>>4//2
2
Pay attention to the decimal point.