+ 1

what does % mean

i think it means percent but in python they gave me this question >>> x = 3 >>> num = 17 >>> print(num % x) and whatever answer i do it says wrong

27th Aug 2018, 2:53 PM
silkycoder
silkycoder - avatar
7 Respostas
+ 4
% for remainder. ______ 3 | 17 |5 ______ 2 answer is 2 because here remainder is 2.
27th Aug 2018, 4:18 PM
Maninder $ingh
Maninder $ingh - avatar
+ 2
me neighter don't know why this has so many votes, lol 😅 17 = 5*3 + 2 (rest, the number after plus, is called the remainder) the modulos operator calculates it 17%3 = 2 that's it
27th Aug 2018, 7:38 PM
Matthias
Matthias - avatar
+ 1
I dont get this? ______ 3 | 17 |5 ______ 2
27th Aug 2018, 4:20 PM
Trigger
Trigger - avatar
0
% gives you the remainder of a division. 13 % 3 == 1
27th Aug 2018, 3:05 PM
HonFu
HonFu - avatar
0
it modolo or modulo (not sure how spelled ...) it means you make a division and the "rest" which is no divisible by the number is left. exemple: 17%3 = 2 16%3 = 1 15%3 = 0 it has multiple uses such as testing if a number is divisible by another number.
27th Aug 2018, 3:10 PM
Anton Böhler
Anton Böhler - avatar
0
fun fact: In Python this also works for floats. Not only for integers. For example 5.3 % 2.5 = 0.3 (because 5.3 = 2*2.5 + 0.3, i.e. rest of 0.3)
27th Aug 2018, 3:29 PM
Matthias
Matthias - avatar
0
This is the modulo operator that returns the remainder of a division. In other languages is might only work for Integers but in Python it also works for floats. This is a program I wrote that demonstrates the use of modulo in a way other than returning the remainder https://code.sololearn.com/c3UUKoI2qycu/?ref=app
27th Aug 2018, 4:16 PM
Trigger
Trigger - avatar