What sign% do? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What sign% do?

I didn't understand what sign (%) do?

8th Dec 2017, 12:29 PM
‎Mohammed Abdullsalam
‎Mohammed Abdullsalam - avatar
7 Answers
+ 4
If you have 7 candies and there are 3 children, how many candies can you give to each one? 7 / 3 = 2 (without decimals, they don't want broken candies) I can give 2 candies to each one and there is one for me. This is the remainder of division. maybe it isn't too much mathematical... 🤔 (All the operations without decimals) remainder_of_division = 7 - (7 / 3) * 3 remainder_of_division = 7 % 3 not much better... 😁😁
8th Dec 2017, 7:22 PM
Enrique
+ 7
@Full Gamer It is slightly different for negative numbers... -37%3 would be 2 in Python and -1 in all other languages (that I know) 37%-3 would be -2 in Python and 1 in all other languages (again, that I know) -37%-3 (should be) 1 in every language. (... that I know.) Hope this helped! 😉
8th Dec 2017, 1:27 PM
blackcat1111
blackcat1111 - avatar
+ 5
In terms of math, the % sign is the modulus operator. 37 MOD 3 = 1 53 MOD 6 = 5 -75 MOD -4 = -3 Hope you understand it now. 😉
8th Dec 2017, 10:00 PM
blackcat1111
blackcat1111 - avatar
+ 2
thank you all
16th Dec 2017, 11:34 PM
‎Mohammed Abdullsalam
‎Mohammed Abdullsalam - avatar
+ 1
what's meant by " remainder in division"?
8th Dec 2017, 2:52 PM
‎Mohammed Abdullsalam
‎Mohammed Abdullsalam - avatar
+ 1
if you explain it mathematically i would be thankful.😊
8th Dec 2017, 2:53 PM
‎Mohammed Abdullsalam
‎Mohammed Abdullsalam - avatar
+ 1
In mathematical signs , % = to what?!
8th Dec 2017, 3:04 PM
‎Mohammed Abdullsalam
‎Mohammed Abdullsalam - avatar