-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ex.35_Dog_Years.py
20 lines (18 loc) · 1.01 KB
/
Ex.35_Dog_Years.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# It is commonly said that one human year is equivalent to 7 dog years.
# However this simple conversion fails to recognize that dogs reach adulthood in approximately two years.
# As a result, some people believe that it is better to count each of the first two human years
# as 10.5 dog years, and then count each additional human year as 4 dog years.
# Write a program that implements the conversion from human years to dog years described in the
# previous paragraph. Ensure that your program works correctly for conversions of less than two human
# years and for conversions of two or more human years. Your program should display
# an appropriate error message if the user enters a negative number.
human_years = (int(input("Please enter your age: ")))
dog_years = 0
if human_years < 0:
print("Please enter only positive numbers.")
elif human_years < 3:
dog_years = human_years * 10.5
else:
dog_years = (human_years - 2) * 4
dog_years += 10.5 * 2
print("Your age in dog years would be: %d" %(dog_years))