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

In this lab, you add the input and output statements to a partially completed Py

ID: 3874054 • Letter: I

Question

In this lab, you add the input and output statements to a partially completed Python program. When completed, the user should be able to enter a year, a month, and a day. The program then determines if the date is valid. Valid years are those that are greater than 0, valid months include the values 1 through 12, and valid days include the values 1 through 31.

Instructions

Notice that variables have been declared for you.

Write input statements to retrieve a year, a month, and a day from the user.

Include the print statements to output the following:

or

Execute the program entering the following input:

Execute the program entering the following input:

Explanation / Answer

#!/usr/bin/python
day = int(input("Enter day:"))
month = int(input("Enter month:"))
year = int(input("Enter year:"))

if(year>=1900 and year<=9999): #Checking valid year from 1900 to 9999. Change the range as needed.
   if(month>=1 and month<=12):
       if((day>=1 and day<=31) and (month==1 or month==3 or month==5 or month==7 or month==8 or month==10 or month==12)):
           print(month,'/',day,'/',year," is a valid date.",sep='')
       elif((day>=1 and day<=30) and (month==4 or month==6 or month==9 or month==11)):
           print(month,"/",day,"/",year," is a valid date.",sep='')
       elif((day>=1 and day<=28) and (month==2)):
           print(month,"/",day,"/",year," is a valid date.",sep='')
       elif(day==29 and month==2 and (year%400==0 or(year%4==0 and year%100!=0))):
           print(month,"/",day,"/",year," is a valid date.",sep='')
       else:
           print(month,"/",day,"/",year," is an invalid date.",sep='')
   else:
       print(month,"/",day,"/",year," is an invalid date.",sep='')
else:
   print(month,"/",day,"/",year," is an invalid date.",sep='')

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