+ 1
Can anyone help me to understand this code?
>>>20//6 = 3 and 1.25% = 0.5 in lesson it state that this code 6 goes into 20 three times, how 6×3 is 18 however 6×3.33333333 is 20 please explain in detail
2 Réponses
+ 2
20//6 = 3 because 6 goes into 20 only three times as a WHOLE number (6*3 = 18). (You can think of it as the rounded down answer if that helps.) The answer is not 3.33, even though that is correct. This is because the // operator checks how many times a number goes into another number as a whole number. To get the exact number (3.33) you would just use the normal / division operator.
0
// is integer division i.e whole number without any remainder
/ is normal division
% is remainder after division