+ 1

What is the meaning of %

python

25th Jul 2017, 4:54 PM
Sabapathi Chettiar
Sabapathi Chettiar - avatar
4 Respostas
+ 4
Modulus gives the remainder of the division of one number by another. 7 % 5 This would return 2 due to the fact that 5 goes into 7 once and then gives the 2 that is left over Note the difference in case of negative numbers- x = 5 % (-3); y = (-5) % (3); z = (-5) % (-3);
25th Jul 2017, 5:03 PM
Apoorva Shenoy Nayak
Apoorva Shenoy Nayak - avatar
+ 3
The '%' symbol is for modulus. Modulus is used to find the remainder of a division. For example: 9 % 4 = 1 8 % 2 = 0 15 % 8 = 7
25th Jul 2017, 5:00 PM
Thomas John
Thomas John - avatar
+ 2
Modular -- It's related to division, but instead you get the remainder In normal integer division the remainder is cut off example: 10/3 = 3 (%1) 5/3 = 1 (%2) But if we use the mod operator we cut the main part of the number off and only keep the remainder: 10%3 = 1 5%3 = 2
25th Jul 2017, 5:01 PM
S C
0
it's a Remainder
26th Jul 2017, 3:56 AM
Kibrom Tsegay
Kibrom Tsegay - avatar