Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren0
How is the answer 0.25 shouldn't it be 2.5
>>> 1.25 % 0.5 0.25
2 Antworten
+ 1
The % operator gives you the remainder of the initial number
For example;
4373789 % 2 = 1
https://code.sololearn.com/W5RqvS7Ir1Jy/?ref=app
+ 1
1.25 = 0.5*2 + 0.25
But if you try 1.4%0.2, it will be 0.2, and 1.4//0.2 is 6.0.
Possible it depends on the internal representation of numbers in python.