Python Forum
New to Coding, help please?!
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New to Coding, help please?!
#4
I am assuming teenage start at 13, right?
do basic arithmetic

teenage_left = 13-x, where x is the user input age
if you want adult
adult_left = 18-x, where x is the user input age

FYI: A lot of coding will involve basic math, so try to
here is an example
user_input = (raw_input("Enter your Age"))
age = int(user_input)
teenage_left = 13-age
if age == 0:
  print "You are a Baby!"
  print "You have", teenage_left, " more years until you are teenager"
elif age == 1 or age == 2:
  print "You are a toddler"
  print "You have", teenage_left, " more years until you are teenager"
elif age == 3 or age == 4:
  print "You are Infant"
  print "You have", teenage_left, " more years until you are teenager"
elif age >= 5 and age <= 12:
  print "You are a Child"
  print "You have", teenage_left, " more years until you are teenager"
else :
  print "Enter a whole number between 0 and 12"
OR ,

you can make it one line at the end, depends on your preference, but I prefer this one, cleaner!

user_input = (raw_input("Enter your Age"))
age = int(user_input)
teenage_left = 13-age
if age == 0:
  print "You are a Baby!"
elif age == 1 or age == 2:
  print "You are a toddler"
elif age == 3 or age == 4:
  print "You are Infant"
elif age >= 5 and age <= 12:
  print "You are a Child"
else :
  print "Enter a whole number between 0 and 12"
print "You have", teenage_left, " more years until you are teenager"
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