How is the answer 0.25 shouldn't it be 2.5 | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

How is the answer 0.25 shouldn't it be 2.5

>>> 1.25 % 0.5 0.25

5th Feb 2019, 4:12 AM
M. Anne
M. Anne - avatar
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
5th Feb 2019, 7:56 AM
eMBee
eMBee - avatar
+ 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.
5th Feb 2019, 6:15 AM
Vladimir {Tomsk}
Vladimir  {Tomsk} - avatar