This is the solution to your first Python problem. The difficulty level is set according to the numbering of the problem, so that being said, it was an easy one. Hope you enjoyed doing it. Along with checking your solution, you can also freshen up your memory by reading the problem statement again.
Take age or year of birth as an input from the user. Store the input in one variable. Your program should detect whether the entered input is age or year of birth and tell the user when they will turn 100 years old. (5 points).
Here are a few instructions that you must have to follow:
yearAge = int(input("What is your Age/Year of birth\n"))
isAge = False
isYear = False
if len(str(yearAge)) == 4:
isYear = True
else:
isAge = True
if(yearAge<1900 and isYear):
print("You seem to be the oldest person alive")
exit()
if(yearAge>2019):
print("You are not yet born")
exit()
if isAge:
yearAge = 2019 - yearAge
print(f"You will be 100 years old in {yearAge + 100}")
interestedYear = int(input("Enter the year you want to know your age in\n"))
print(f"You will be {interestedYear - yearAge} years old in {interestedYear}")
No downloadable resources for this video. If you think you need anything, please post it in the QnA!
Any Course related announcements will be posted here
Be the first person to comment!