Just did the Basic module quiz - Why is the answer what it is? please help, logically does not make sense at the moment! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Just did the Basic module quiz - Why is the answer what it is? please help, logically does not make sense at the moment!

What is the output of this code? >>> x = 3 >>> num = 17 >>> print(num % x)

19th Feb 2017, 12:52 PM
gnqayi
4 Answers
+ 5
that is not the divide operator it is the modulo operator it returns the remainder from the division 17/3 just look at the closest number which is divisable by 3, that is 15 as 15/5=3 and the difference from 15 to 17 is 2
19th Feb 2017, 1:40 PM
Burey
Burey - avatar
+ 4
17=15+2=(3+3+3+3+3)+2
19th Feb 2017, 1:08 PM
Burey
Burey - avatar
+ 1
Thanks for answering and forgive my stupidity but still don't get it. if X = 3 and num = 17 and the % means to divide, then why 2. like i said why is the answer the answer?
19th Feb 2017, 1:28 PM
gnqayi
+ 1
Thanks Burey, got it
19th Feb 2017, 2:02 PM
gnqayi