KnowledgeBoat Logo

Computer Science

Write a program that asks a user for a number of years, and then prints out the number of days, hours, minutes, and seconds in that number of years.

How many years? 10
10.0 years is:
3650.0 days
87600.0 hours
5256000.0 minutes
315360000.0 seconds

Python

Python Data Handling

41 Likes

Answer

y = float(input("How many years? "))

d = y * 365
h = d * 24
m = h * 60
s = m * 60

print(y, "years is:")
print(d, "days")
print(h, "hours")
print(m, "minutes")
print(s, "seconds")

Output

How many years? 10
10.0 years is:
3650.0 days
87600.0 hours
5256000.0 minutes
315360000.0 seconds

Answered By

17 Likes


Related Questions