Programming Examples

Python program that asks a user for a number of years and then prints out the number of days hours minutes and seconds


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

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad