-
Notifications
You must be signed in to change notification settings - Fork 0
/
age-quiz.py
31 lines (27 loc) · 927 Bytes
/
age-quiz.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
def evaluate_age(age):
"""
Evaluates the age of the user and prints a message accordingly.
"""
if age < 13:
print("You qualify for the kiddie discount (under 13 years old).")
elif age == 21:
print("Congratulations on your 21st birthday!")
elif age > 100:
print("Sorry, you are considered to have reached the end of life expectancy.")
elif age >= 65:
print("Enjoy your retirement!")
elif age >= 40:
print("You are over the hill, but life is just beginning!")
else:
print("Age is but a number - you are in the prime of your life!")
def main():
"""
Main function to get user's age and evaluate it.
"""
try:
age = int(input("Enter your age: "))
evaluate_age(age)
except ValueError:
print("Invalid input! Please enter a valid age.")
if __name__ == "__main__":
main()