In Python, what happens to a remainder of 2%7 ? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

In Python, what happens to a remainder of 2%7 ?

I'm clueless, please help! How Python processes a remainder of a dizimal quotient?

15th Apr 2018, 1:45 AM
Jonatas Siqueira Lopes
Jonatas Siqueira Lopes - avatar
2 Respostas
15th Apr 2018, 1:53 AM
Nithiwat
Nithiwat - avatar
+ 2
The answer to the problem you provided IS the remainder. You're using the modulus (or modulo) operator (%). It returns the remainder of the division. In this case it returns 2. Now, the real answer is actually -2, but I believe Python returns the positive because two positives were originally used. Check out the forums below for a complete explanation. https://ubuntuforums.org/showthread.php?t=498178
15th Apr 2018, 3:07 AM
synorax
synorax - avatar