0
1024 / 42 , 1024 // 42 , 1024 % 42 what is the difference between them?
?? Can anyone explain https://code.sololearn.com/cbALfqNk4Lz6/?ref=app https://code.sololearn.com/cbALfqNk4Lz6/?ref=app
1 Answer
+ 4
"/" is for normal division and returns a float.
"//" is for floor division. It only gives you the whole number as an integer. It drops the decimals.
"%" is the modulo operator it returns the remainder.
Example:
9 / 6 = 1.5
9 // 6 = 1
9 % 6 = 3
And for the future
https://code.sololearn.com/W3uiji9X28C1/?ref=app