Can anyone help me to understand this code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

3rd Mar 2016, 5:56 PM
camzee
2 Answers
+ 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.
12th Mar 2016, 7:21 AM
Antonio
Antonio - avatar
0
// is integer division i.e whole number without any remainder / is normal division % is remainder after division
3rd Jul 2016, 11:04 AM
Yashil
Yashil - avatar