Python Forum
New to Coding, help please?!
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New to Coding, help please?!
#1
Write a python program that prompts the user to enter in their age. Convert the keyboard input into an integer using the int( ) function and store the result into a variable. Don't worry about your program crashing on invalid input.
Use an if-elif chain (chained conditionals) to test the user age against a series of ranges. The program should print a message classifying the user's age. Use the following age ranges to determine what message to print.

0 - Baby
1, 2 = Toddler
3,4 = Infant
5, 12 = Child

Enter your age:  7
You are a child of age 7.
You have 6 more years until your are a teenager!


Please help me with my coding. I know how to do the Toddler, Infant, and Child coding. Also, how can I get it to tell how many years until they move up to the next age bracket?
age = int(input("Enter your age:)
if age > 0 and age <1:
print("You are a Baby")
Moderator sparkz_alot:
Moved from General Coding, add code tags.  In the future use the proper code tags, post in the correct section and title your thread to reflect your question. 

Refer to the HELP Document.
Reply


Messages In This Thread
New to Coding, help please?! - by zepel - Apr-20-2017, 01:20 AM
RE: New to Coding, help please?! - by sdcaliber - Apr-20-2017, 01:49 AM
RE: New to Coding, help please?! - by zepel - Apr-20-2017, 03:29 AM
RE: New to Coding, help please?! - by sdcaliber - Apr-20-2017, 04:01 AM
RE: New to Coding, help please?! - by sdcaliber - Apr-20-2017, 04:18 AM
RE: New to Coding, help please?! - by zepel - Apr-20-2017, 04:15 AM
RE: New to Coding, help please?! - by volcano63 - Apr-20-2017, 08:33 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020