administrata a écrit :
Hi! it's been about a week learning python!
I've read 'python programming for the absolute begginer'
I don't understand about % like...

107 % 4 = 3
7 % 3 = 1

it's the modulo operator (if you don't remember, the modulo is the remaining of the integer division, ie 5 % 2 = 1)


One of the most commun use is to test wether a number is odd or even:

any_even_number % 2 == 0
any_odd_number % 2 == 1


Note that the % operator is also used for string formating, ie: "%d modulo %d = %d" % (5, 2, 1) => "5 modulo 2 = 1"

Please help me...
HTH
Bruno
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to