Question 2
Write a Python program to check whether a given date is valid date or not and to out put the following.
• If the date is valid then the message “Date is Valid” otherwise the message “Date is Invalid”.
• If the date is a valid date, then the next date.
Hint: Follow the following steps.
(NOTE: You are not allowed to use any Python built-in functions.)
• Get the inputs Year, Month, and Date separately.
• Use selection statements, i.e., if-else statements to check if the Date, Month, and the Year are valid.
• if the date is a valid date, then print the next date (Increment the date).
date = int(input())
months = int(input())
year = int(input())
if date > 0 and date < 32 and months > 0 and months < 13 and year > 0:
print(date + 1)
else: print("Invalid date")
Comments
Leave a comment