0
How come when you do "1.25%0.5" it give you 0.25 as the remainder but normally when you try "1.25 ÷0.5" it give you 2.5?
It's kind of confusing and I really need help
4 Respuestas
+ 3
Floor division and modulo work as a team.
Floor division finds out, how many cookies you and your friends get.
Modulo finds out how many cookies will be left over.
cookies = 23
friends = 3
share = cookies // friends
cookies_left = cookies % friends
Everyone's share will be 7.
2 cookies will be left.
With float, it is basically the same: 0.5 fits two times into 1.25, and 0.25 will be left over.
0
It's really easy.
Look at this:
https://code.sololearn.com/cZNhTMAUw2Qg/?ref=app
0
% gives you remainder and / gives you quotient.