Correct date X54516


Statement
 

pdf   zip

html

Write a boolean function correct_date(d,m,y) that tells us whether day d of month m of year y represents an actually correct date. Argument y is always an int between 1800 and 9999. The rules to decide on february 29 for this interval of years can be found in exercise X91228: “Leap Years (2)”.

Sample session
>>> correct_date(30, 11, 1971)
True
>>> correct_date(6, 4, 1971)
True
>>> correct_date(4, 8, 2001)
True
>>> correct_date(29, 2, 2001)
False
>>> correct_date(32, 11, 2005)
False
>>> correct_date(30, 11, 2004)
True
>>> correct_date(-20, 15, 2000)
False
Information
Author
José Luis Balcázar
Language
English
Official solutions
Python
User solutions
Python