what does num mean in python 3? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

what does num mean in python 3?

how do i use 'num' in python 3? Here is some code: x=3 num=17 print(num % x) ...the output will be 2. My question is how does it come to that answer/output? THANKS

19th Aug 2017, 6:36 AM
reggie
reggie - avatar
3 Answers
+ 4
num is a variable like x num % x is equal to 17 % 3. The nearest multiple of 3 from 17 and smaller than 17 is 15, so the remainder of the division of 17 by 3 is 17-15 so 2
19th Aug 2017, 6:51 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 1
% = modulo which basically is "how much will be left over after the nearest Full multiplication with 3 that results less than 17" 5*3 = 15 17-15=2 if you did it with 18 it would be 0 since 6*3 = 18 if you did for example 10%6 6*1 = 6 10-6=4 or you could think it with division since multiplication and division walk hand in hand
1st Mar 2018, 10:37 PM
Markus Kaleton
Markus Kaleton - avatar
0
А на русском?
30th Aug 2021, 4:51 PM
Djek Evil
Djek Evil - avatar