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 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz