I am trying to write a python program to calculate the number of days in a year,by reading through a text file and telling if the date is valid(and if valid,list the number of days in the year),or invalid.I have come up with the folowing code but i am kinda stuck from here on how to calculate the number of days.i will appreciate if someone can look through my codes and help modify or add where necessary.thanks
def isleapYear(year): if year % 400 == 0: return True elif year % 100 == 0: return False elif year % 4 == 0: return True else: return False def validate(m,d,y): if m == 4: d == 30 return True elif m == 6: d == 30 return True elif m == 9: d == 30 return True elif m == 11: d == 30 return True elif m == 2: if isleapYear(year): d == 29 return True else: d == 28 return True else: d == 31 return True def dayNum(m,d,y): dayNum = 31(m - 1) + d if m == 2: dayNum == (4m + 23)/10 return dayNum
i am stuck on how to go about invoking the last two functions in def dayNum(m,d,y),and calculating the number of days.
Edited by Dogstopper: Please,
ESPECIALLY since Python is whitespace sensitive, code tags are very important.
This post has been edited by Dogstopper: 12 March 2010 - 04:32 PM