0

in the float lesson it for division a single forward slash was used but in numeric operators it uses 2 forward slashes why??

2nd Feb 2017, 1:58 AM
Xmea
Xmea - avatar
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.
2nd Feb 2017, 2:28 AM
DaemonThread
DaemonThread - avatar
+ 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.
2nd Feb 2017, 2:30 AM
Reginaldo Junior
Reginaldo Junior - avatar