From cf7b6e733cf67ecc1991b58de3d441107098c879 Mon Sep 17 00:00:00 2001 From: cheeks <134818917+leftovertoast@users.noreply.github.com> Date: Wed, 22 Jan 2025 17:27:52 -0500 Subject: [PATCH] Completed 5-6 Stages of Life --- Chapter_05/5-06_stage_of_life.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Chapter_05/5-06_stage_of_life.py diff --git a/Chapter_05/5-06_stage_of_life.py b/Chapter_05/5-06_stage_of_life.py new file mode 100644 index 0000000..d70f34e --- /dev/null +++ b/Chapter_05/5-06_stage_of_life.py @@ -0,0 +1,30 @@ +# Exercise 5-6 Stage of Life +# Learning Objective: write if-elif-else chain. + +''' +# test +variable1 = '23' +if type(int(variable1)) == int: + print(variable1) +else: + print("Invalid") +''' +myAge = input('Please enter an age: ') + +if type(int(myAge)) != int: + print("\nYou've entered an invalid value. Exiting..") +elif int(myAge) < 2: + print('\nThis person is just a baby.') +elif (int(myAge) >= 2) and (int(myAge) < 4): + print('\nThis person is a toddler.') +elif (int(myAge) >= 4) and (int(myAge) < 13): + print('\nThis person is a kid.') +elif (int(myAge) >= 13) and (int(myAge) < 20): + print('\nThis person is a teenager.') +elif (int(myAge) >= 20) and (int(myAge) < 65): + print('\nThis person is an adult') +elif int(myAge) >= 65: + print('This person is an elder.') + +# There's a better way to do this. +