Test_niikoru.mp3

Code test for niikoru.mp3
mail@pastecode.io avatar
unknown
python
2 years ago
897 B
3
Indexable
Never
import traceback

def calculator():
    age = input("Input dog years: ")
    flag = False

    try:
        d_age = float(age)
        human_age = 0

        if d_age < 0:
            flag = True
        elif 0< d_age <=1:
            human_age += d_age*15.0
        elif 1< d_age <=2:
            human_age += d_age*15.0
        elif 2< d_age <=3:
            human_age += d_age*15.0
        elif 3< d_age <=4:
            human_age += d_age*15.0
        elif 4< d_age <=5:
            human_age += d_age*15.0
        else:
            human_age += 5*7.2+(d_age-5)*7.0

        if flag == False:
            print("The given dog age ", d_age, " is ", round(human_age,2)," in human years.")
        else:
            print("Age cannot be a negative number.")
    except:
        print(age, " is an invalid age.")
        print(traceback.format_exc())

calculator()