TORONTO KIDS COMPUTER CLUB | Sunday 9:45 Python Homework 10.21.
15891
post-template-default,single,single-post,postid-15891,single-format-standard,ajax_fade,page_not_loaded,,no_animation_on_touch,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Sunday 9:45 Python Homework 10.21.

24 Oct Sunday 9:45 Python Homework 10.21.

Question :

write a program to ask user about the date(year, month and day), then calculate the day of the year.

 


Sample input:

Year: 2016
Month: 6
Day: 23

Sample output:

Day of the year: 175


Hint:

You need consider leap years and non leap years, in order to do easier calculation, you may create a list to contain all the days in each month:

if it is a leap year, then mo = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], otherwise, mo = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

 

No Comments

Sorry, the comment form is closed at this time.