+ 2

what is %

8th Aug 2016, 8:14 AM
usman
4 Respuestas
+ 3
modulo. it gives you the remainder after dividing example: num = 10 remainder = num%2 # remainder is zero print("The number 10 is even") num = 11 remainder = num%2 #remainder is one print("The number 11 is odd")
8th Aug 2016, 10:17 AM
Izz
Izz - avatar
+ 1
modulu
8th Aug 2016, 10:15 AM
‫Ido Tal
‫Ido Tal - avatar
+ 1
better yet, numIn = input("Please enter a number: ") if numIn%2 == 0 print("The number you entered is even") else print("The number you entered is odd") note: I trust the user to insert an integer, because I skipped error handling. this is simplest example to show modulo. can be very powerful. :)
8th Aug 2016, 10:21 AM
Izz
Izz - avatar
+ 1
I get it thanks
8th Aug 2016, 11:09 AM
usman