Python Forum
python age calculator need to find the number of years before they turn 100 not using
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python age calculator need to find the number of years before they turn 100 not using
#1
[font=Times New Roman, Times, serif]
I am new at python and i'm trying to teach myself the best way i can. So i will make noob mistakes. I was wondering if you could tell me where my code is going wrong and how i could improve it?

I have been trying to make a simple age calculator as part of the questions i have recieved at school.

The question is:

Write a program that asks the user to enter their age (in years).

- If the user is 100 or older, tell them You've already turned 100!.
- If they are less than 0, tell them Try again after you are born!.
- If neither of these cases apply, calculate the number of years before they turn 100 and output the message You will be 100 in x years! (where x is - replaced by the number of years before they turn 100).
- You must use an if...elif...else statement for this problem.

my code


age = int(input("Enter your current age in years: "))

if (age >= 100):
   print("You've already turned 100!.") 

elif:
     for age in range( 0 > -100:)
     print("Try again after you are born!.")

else:
     x = (int(age - 100 ))
     print("You will be 100 in" x "years!" )
Reply


Messages In This Thread
python age calculator need to find the number of years before they turn 100 not using - by orangevalley - Mar-25-2018, 09:10 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to find the next prime number FirstBornAlbratross 8 4,335 Aug-14-2023, 01:16 PM
Last Post: deanhystad
  Calculate AGE in years Kessie1971 17 3,519 Apr-26-2023, 03:36 PM
Last Post: deanhystad
  Python Program to Find the Factorial of a Number elisahill 2 1,439 Nov-21-2022, 02:25 PM
Last Post: DeaD_EyE
  Tracking leap.py years for gregorian calendar (Exercism org) Drone4four 11 3,802 Oct-14-2022, 03:20 PM
Last Post: betinajessen
  Python calculator help but not using while loop with true, any flags variable ,break kirt6405 13 5,772 Jun-08-2021, 06:39 AM
Last Post: Larz60+
  Calculator: several options, changing the number gus17 4 3,251 Dec-28-2019, 11:22 PM
Last Post: ichabod801
  How to find the accuracy vs number of neighbours for KNN vokoyo 3 3,173 Apr-10-2019, 03:46 AM
Last Post: scidam
  Problem with code to calculate weekday for leap years! Event 2 2,852 Dec-15-2018, 05:13 PM
Last Post: Event
  i need help in fixing my scientific calculator coding : (, im using python 3.5.5 hans77 1 4,177 Oct-17-2018, 03:26 AM
Last Post: stullis
  how to find a next prime number? iamyourfather 2 6,519 Oct-01-2017, 04:21 PM
Last Post: gruntfutuk

Forum Jump:

User Panel Messages

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