+ 2

What does % do in python ?

for an example if (list)%2==0 means?

23rd Mar 2018, 6:22 AM
Sajid Ameen
Sajid Ameen - avatar
5 Answers
+ 16
% Modulus operator divides left hand operand by right hand operand and returns remainder 6%4 = 2 4%4 = 0 -4%6 = -4 -6%4 = -2 -6%-4 = -2
23rd Mar 2018, 6:29 AM
Nithiwat
Nithiwat - avatar
+ 4
Modulus operator returns the reminder after dividing the first number with the second one. If the first number is smaller than the second, then the quotient will be zero while the remainder will be the first number itself. If both the numbers are perfectly divisible, remainder will be zero.
23rd Mar 2018, 6:35 AM
Baraa AB
Baraa AB - avatar
+ 4
% means modulus. It gives remainder. (list) % 2==0 means that (list) must be divisible by 2 so that it will leave a remainder 0.
11th May 2018, 11:42 AM
Soumyajit Chand
Soumyajit Chand - avatar
+ 1
thanks for your help
23rd Mar 2018, 6:31 AM
Sajid Ameen
Sajid Ameen - avatar
+ 1
เยี่ยมครับ
31st Mar 2018, 9:28 AM
Panupong Boonlong
Panupong Boonlong - avatar