Use you may use the following simple python script to convert a dog's age to human years.
dog_age = int(input("Enter your dog's age in years: ")) if dog_age <= 0: print("Please enter a valid age greater than zero.") elif dog_age == 1: human_age = 15 elif dog_age == 2: human_age = 24 else: human_age = 24 + (dog_age - 2) * 5 print("Your dog's age in human years is:", human_age)
- If the dog's age is 1, the script sets the human age to 15.
- If the dog's age is 2, the script sets the human age to 24.
- If the dog's age is greater than 2, the script uses the formula human_age = 24 + (dog_age - 2) * 5 to calculate the dog's age in human years.