+ 2

can someone teach how to find the answer of >>>x=3 >>> num=17 print (num%x) and the mind of the (%) in this code

please help me i don't understand

9th Sep 2016, 4:47 PM
Tristan Aryo
Tristan Aryo - avatar
9 ответов
+ 9
% (modulus) gives you the modulo, ie the remainder of the euclidian division. For example: 42%9 is 6, because 42 = 9*4 + 6 x%y is 0 if x is a multiple of y x%1 is always 0 x%2 is 0 if x is even and 1 if it is odd x%10 gives you the last digit of x x%100 gives you the last two digits of x etc.
9th Sep 2016, 5:21 PM
Zen
Zen - avatar
+ 3
This sign(%) is called MODULO and It is used to get remainder. The Answer is 2
9th Sep 2016, 5:00 PM
Moulik Aggarwal
Moulik Aggarwal - avatar
+ 1
As we divide to numbers and we get the remainder.... Modulo function also divides teo operands and gives the remainder in the result....
10th Sep 2016, 6:40 AM
khushboo kotadia
khushboo kotadia - avatar
+ 1
Well I don't know about python, but usually the % divides your numbers and returns the remainder. Let's use your code. >>>x=3 >>> num=17 print (num%x) Your dividing 17 by 3 and looking for the remainder. 17/3=(3*5)+2. The 2 is the remainder because it's extra addition to get you 17. In reality, it would be a decimal of some sort. Get it?
20th Oct 2016, 2:06 AM
EnderGeneral149
EnderGeneral149 - avatar
0
thx for the answer but is still not understan how "MODULO" work
9th Sep 2016, 5:03 PM
Tristan Aryo
Tristan Aryo - avatar
0
Si tu es français, c'est une division à restes. Le reste est le resultat. Else, it does a division and shows its remaining value. In 17, there is 3*5. 3*6 gives 18 so the result is 3*5 =15 ; 17-15 =2.
9th Sep 2016, 10:28 PM
Jérémy
Jérémy - avatar
0
oui je le suis
9th Sep 2016, 10:31 PM
Tristan Aryo
Tristan Aryo - avatar
0
thx for the answer
9th Sep 2016, 10:32 PM
Tristan Aryo
Tristan Aryo - avatar
0
Thanks to Moulik
28th Jun 2020, 6:44 PM
Faith Mundi
Faith Mundi - avatar