Convert Cat's Age to Human Years using Python

Use you may use the following simple python script to convert a cat's age to human years.

Convert Cat's Age to Human Years using Python
Photo by Manja Vitolic / Unsplash

Use you may use the following simple python script to convert a cat's age to human years.

cat_age = int(input("Enter cat's age in cat years: "))

if cat_age == 0:
    human_age = 0
elif cat_age == 1:
    human_age = 15
elif cat_age == 2:
    human_age = 24
else:
    human_age = 24 + (cat_age - 2) * 4

print("Cat's age in human years is", human_age)

Notes:

  • If the cat's age is 1, the script sets the human age to 15.
  • If the cat's age is 2, the script sets the human age to 24.
  • If the cat's age is greater than 2, the script uses the general formula of multiplying each cat year by 4 to get the equivalent human years.