+ 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
9 Respostas
+ 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.
+ 3
This sign(%) is called MODULO and It is used to get remainder.
The Answer is 2
+ 1
As we divide to numbers and we get the remainder.... Modulo function also divides teo operands and gives the remainder in the result....
+ 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?
0
thx for the answer but is still not understan how "MODULO" work
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.
0
oui je le suis
0
thx for the answer
0
Thanks to Moulik