Programming Assignment: Homework 1b - Practice Writing Python & Calculating How Old Your Dog is in Human Years

import traceback

def calculator():

    # Get dog age
    age = input("Input dog years: ")

    try:
        # Cast to float
        d_age = float(age)

        # If user enters negative number, print message
        # Otherwise, calculate dog's age in human years

        if d_age < 0 :
            print('Age cannot be a negative number.')
        elif d_age <= 1.0 and d_age > 0 :
            h_age = 15 * d_age
        elif d_age <= 2.0 and d_age > 1.0 :
            h_age = 12 * d_age
        elif d_age <= 3.0 and d_age > 2.0 :
            h_age = 9.3 * d_age
        elif d_age <= 4.0 and d_age > 3.0 :
            h_age = 8 * d_age
        elif d_age <= 5.0 and d_age > 4.0 :
            h_age = 7.2 * d_age
        else:
            h_age = ( 7 * d_age ) + 1

        print(f'The given dog age {round(d_age,2)} is {round(h_age,2)} in human years.')

    except:
        print(age, "is an invalid age.")
        print(traceback.format_exc())

calculator() # This line calls the calculator function