# CS 1231 Python Program to Calculate a Dog's Age in Dog's Years

Content type
User Generated
Subject
Computer Science
Type
Other
Rating
Showing Page:
1/3
PROGRAMMING SET <<NUMBER>>
Name:
JUAN M DELA CRUZ
Student No:
201801XXXXX
Instructor:
Asst. Prof. EJ Antonio
Course Code:
NME2210 ME1
Problem 1:
(Dog Years) Write a Python program to calculate a dog's age in dog's years. Note: For the first
two years, a dog year is equal to 10.5 human years. After that, each dog year equals 4 human
years.
Source Code:
h_age = int(input("Input a dog's age in human years: "))
if h_age < 0:
print("Age must be positive number.")
exit()
elif h_age <= 2:
d_age = h_age * 10.5
else:
d_age = 21 + (h_age - 2)*4
print("The dog's age in dog's years is", d_age)
Sample Output:

Showing Page:
2/3
PROGRAMMING SET <<NUMBER>>
Name:
JUAN M DELA CRUZ
Student No:
201801XXXXX
Instructor:
Asst. Prof. EJ Antonio
Course Code:
NME2210 ME1
Problem 2:
(Dog Years) Write a Python program to calculate a dog's age in dog's years. Note: For the first
two years, a dog year is equal to 10.5 human years. After that, each dog year equals 4 human
years.
Source Code:
h_age = int(input("Input a dog's age in human years: "))
if h_age < 0:
print("Age must be positive number.")
exit()
elif h_age <= 2:
d_age = h_age * 10.5
else:
d_age = 21 + (h_age - 2)*4
print("The dog's age in dog's years is", d_age)
Sample Output:

Showing Page:
3/3

Unformatted Attachment Preview
PROGRAMMING SET – Name: JUAN M DELA CRUZ Student No: 201801XXXXX Instructor: Asst. Prof. EJ Antonio Course Code: NME2210 – ME1 Problem 1: (Dog Years) Write a Python program to calculate a dog's age in dog's years. Note: For the first two years, a dog year is equal to 10.5 human years. After that, each dog year equals 4 human years. Source Code: h_age = int(input("Input a dog's age in human years: ")) if h_age < 0: print("Age must be positive number.") exit() elif h_age ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

### Review

Anonymous
Excellent! Definitely coming back for more study materials.

Studypool
4.7
Indeed
4.5
Sitejabber
4.4