[Tutor] How to test for a remainder from division
kent37 at tds.net
Tue May 15 16:14:59 CEST 2007
Matt Smith wrote:
>> Here is the implementation of calendar.isleap():
>> def isleap(year):
>> """Return 1 for leap years, 0 for non-leap years."""
>> return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)
> Hi Kent,
> Thanks for the help. For future reference how do I go look at the
> implementation of a particular function (the ones coded in Python, I
> don't know C)?
Look in the lib directory that was installed with Python. The location
varies. On Windows look for C:\Python2.x\Lib. My Mac has it at
In the python interpreter, try
>>> import sys
The lib directory will be listed as one element of sys.path.
More information about the Tutor