[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

On 02/11/2014 07:06 PM, Scott W Dunning wrote: > I just have a simple question. I don?t understand why 1%10 = 1? > > I think because 1 is evenly divisible by 10 exactly 0 times with a 1 remainder. I mean int(1 / 10) == 0, with a 1 remainder. The same is true for all numbers leading up to 10. for i in range(12): print('{} % 10 == {}'.format(i, i % 10)) 0 % 10 == 0 1 % 10 == 1 2 % 10 == 2 3 % 10 == 3 4 % 10 == 4 5 % 10 == 5 6 % 10 == 6 7 % 10 == 7 8 % 10 == 8 9 % 10 == 9 10 % 10 == 0 11 % 10 == 1 You can see that with the divmod() function also. -- \?\ /?/\ \ \/??\/ / / Christopher Welborn (cj) \__/\__/ / cjwelborn at live?com \__/\__/ http://welbornprod.com

- Prev by Date:
**Simple % question** - Next by Date:
**Simple % question** - Previous by thread:
**Simple % question** - Next by thread:
**Simple % question** - Index(es):