+ 1

What does 12//3 mean?

24th Mar 2018, 2:12 PM
mystiquexman W
mystiquexman W - avatar
4 Answers
+ 1
// is used for integer division . outputs 12//3 =4 where as 12 /3=4.0
24th Mar 2018, 2:14 PM
Manorama
Manorama - avatar
+ 1
Ah division , but they use // instead of / like other languages. Thanks for your answer.
24th Mar 2018, 2:16 PM
mystiquexman W
mystiquexman W - avatar
+ 1
The // operator is known as a floor divider. What it does is it divides the 2 operands provided in the equation, leaving out the remainder, or alternatively, it sees how many times the second operand can be added to itself before going over the first operand. So as it does have some aspects of division, // is not the same as /. For example, take the equation 15//4. If the two operands were to be divided, then 3.8 would have been returned. Because this is floor division though, it rounds that down to a whole number, returning 3.
24th Mar 2018, 2:32 PM
Faisal
Faisal - avatar
+ 1
Really appreciate for your detailed explanation . :) Faisal.
24th Mar 2018, 2:51 PM
mystiquexman W
mystiquexman W - avatar