+ 1
Porque? Because?
Because it's 2 !!!! , I do not get it..... x=3 nom=17 print(nom%x) because!!!!!
5 Answers
+ 23
^_^
17%3==2
(%) modulo/modulus operator returns the remainder of a perfect division...
+ 1
Sometimes, a real world example helps:
Imagine that you need to distribute real world items among people.
Imagine that these items only have a worth or do function as a whole: think in a usb stick or a bluray disc. A slice of an usb stick does not make any sense and a bluray disc is not a cake either.
Now try to devide 17 usb sticks among 5 guys:
- Everybody gets 3 whole devices that will work. This makes a total of 15 devices
- You will not break the remaining (17-15) = 2 usb sticks to pieces and divide that among the guys. Instead, you just keep them and tell your friends that you have just explained the modulo operator to them. The lesson wasn't for free ;-)
By the way, there is a strongly related operation in python: divmod.
You might want to play with https://code.sololearn.com/ckewgH45GQq7
0
I do not understand, would not it be 5.6 or 5.7 approaching?Where does that 2 come from?
0
So when the division is made with the% sign the answer always the rest of a division / normal? True? Or am I still wrong?