Skip to content

Commit f2a05ae

Browse files
committed
Contributing my Python project by the name of Dog Age Calculator in this repository.
1 parent 4d90840 commit f2a05ae

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Request input from the user to provide a dog's age in human years and convert it to an integer
2+
h_age = int(input("Input a dog's age in human years: "))
3+
4+
# Check if the entered age is less than zero; if true, display an error message and exit the program
5+
if h_age < 0:
6+
print("Age must be a positive number.")
7+
exit()
8+
# If the entered age is 2 years or less, calculate the dog's age in dog's years using the formula 10.5 times the human years
9+
elif h_age <= 2:
10+
d_age = h_age * 10.5
11+
# For ages greater than 2, calculate the dog's age in dog's years using the formula 21 plus 4 times the remaining human years after 2
12+
else:
13+
d_age = 21 + (h_age - 2) * 4
14+
15+
# Display the calculated dog's age in dog's years
16+
print("The dog's age in dog's years is", d_age)

0 commit comments

Comments
 (0)