My life calculater project
Question: I'm currently working on a life calculator that i have programmed in python. I
need ideas of what to add to it and examples on how to add it and also how do
i add a end control so i can just input end and the program stops. I'm trying
to make this better because i plan to take it to a technology fair im going
to. Here is my code.

    
    
    print("The Life Calculator")
    
    
    name = input("What is you're name? ") 
    age = int(input("age:  "))
    
    
    months = age * 12                 #This equals to how many months you have been alive.
    
    
    days = age * 365                  #This equals to how many days you have been alive.
    
    
    hours = age * 8765.81             #This equals to how many hours you have been alive.
    
    
    minutes = age * 31556926          #This equals to how many minutes you have been alive.
    
    
    seconds = age * 3.156e+7          #This equals to how many seconds you have been alive.
    
    
    miliseconds = age * 3.15569e10    #This equals to how many miliseconds you have been alive.
    
    
    microseconds = age * 3.156e+13    #This equals to how many microseconds you have been alive.
    
    
    nanoseconds = age * 3.156e+16     #This equals to how many nanoseconds you have been alive.
    
    
    
    
    
    print("This is how many months you have been alive.")               
    print (months)        #This shows how many months you have been alive.
    
    print("This is how many days you have been alive.")
    print (days)         #This shows how many months you have been alive.
    
    print("This is how many hours you have been alive.")
    print (hours)         #This shows how many hours you have been alive.
    
    print("This is how many minutes you have been alive.")
    print (minutes)       #This shows how many minutes you have been alive.
    
    print("This is how many seconds you have been alive.")
    print (seconds)       #This shows how many seconds you have been alive.
    
    print("This is how many miliseconds you have been alive.")
    print (miliseconds)   #This shows how many miliseconds you have been alive.
    
    print("This is how many microseconds you have been alive.")
    print (microseconds)  #This shows how many microseconds you have been alive.
    
    print("This is how many nanoseconds you have been alive.")
    print (nanoseconds)   #This shows how many nanoseconds you have been alive.
    
    lastline = ("this is how long you have been alive, so what are you going to do with the rest of your life?")
    
    print (name)
    
    print (lastline)
    


Answer: Here is a spiffed-up version.

I took a lot of the repetitive statements and converted them to data:

    
    
    from collections import namedtuple
    
    TimeUnit = namedtuple("TimeUnit", ["name", "per_year"])
    
    units = [
        TimeUnit("decade",            0.1 ),
        TimeUnit("month",            12.0 ),
        TimeUnit("fortnight",        26.09),
        TimeUnit("day",             365.25),
        TimeUnit("hour",           8765.81),
        TimeUnit("minute",        31556926),
        TimeUnit("second",        3.156e+7),
        TimeUnit("millisecond", 3.15569e10)
    ]
    
    def get_float(prompt):
        while True:
            try:
                return float(input(prompt))
            except ValueError:
                pass
    
    def main():
        print("The Life Calculator")
    
        name = input("What is your name? ") 
        years = get_float("What is your age? ")
    
        print("You have been alive for:")
        for unit in units:
            print("  {} {}s".format(years * unit.per_year, unit.name))
        print("what are you going to do with the rest of your life, {}?".format(name))
    
    if __name__ == "__main__":
        main()
    

