Pls help with Python math | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Pls help with Python math

Hi, guys! In Python explanations they write >>> 20 // 6 3 >>> 1.25 % 0.5 0.25 Let alone the fact that I do not get this math, when I execute in the console I get 20//6 ==3 and 20%6 ==2. Why in their text mod is 1.25? Why in console mod is 2? In real life 20/6 is 3.(3)!!! Where am I wrong???

16th May 2018, 4:42 AM
DMR
4 Answers
+ 4
20%6 is 2. It calculates how much remainder there is after the division. 20:6=3 2Remainder That's why 20%6=2
16th May 2018, 4:48 AM
Paul Grasser
Paul Grasser - avatar
0
Thank you, lads. Is % in Python different from % in C++?
16th May 2018, 5:09 AM
DMR
0
no , % is modulus sign remains same in all python and c++
16th May 2018, 5:14 AM
Rajeeb
0
ok. I think I got it. thank you
16th May 2018, 5:20 AM
DMR