Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The days of the year are often numbered from 1 through 365(or 366). This number

ID: 3652450 • Letter: T

Question

The days of the year are often numbered from 1 through 365(or 366). This number can be computed in three steps.
1. dayNum=31(month-1)+day
2. if the month is after February subtract (4(month)+23)//10
3. if its a leap year and after February 29, add 1.

Write a python program that accepts a date as month/day/year, verifies that it is a valid date and then calculates the corresponding day number.

Explanation / Answer

def leap_year(year): year = input(" Enter a year:") if year % 4 == 0: if year % 100 != 0: print " This is a leap year." else: if year % 400 == 0: print " This is a leap year." else: print " This is not a leap year." else: print " This is not a leap year." def valiDate(): date = raw_input(" Enter a date (mm/dd/yyyy):") month,day,year = date.split("/") numDay = 31 * (int(month) - 1)+ int(day) days = [0,31,29,31,30,31,30,31,31,30,31,30,31] try: int(day) > 0 and int(day) 2: numDay = numDay - (4*int(month) + 23)/10 + 1 else: numDay = numDay else: if int(month) > 2: numDay = numDay - (4*int(month) +23)/10 else: numDay = numDay print " Day Number is", numDay except IndexError: print " Invalid Date."
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote