CBSE Class 11 Computer Science
Question 158 of 173
Data Handling — Question 10
Back to all questions 10
Question Question 10
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
Solution
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