Answer:
time = float(input(" Input Time in Seconds: "))
years = time // (365*24*60*60)
time = time % (365*24*60*60)
day = time // (24*3600)
time = time % (24*3600)
hour = time // 3600
time = time % 3600
minutes = time // 60
time = time % 60
seconds = time
print(years,"years")
print(day, "days")
print(hour, "hours")
print(minutes, "minutes")
print(seconds, "seconds")
Step-by-step explanation:
The code is written in python programming language.
Line 1: time = float(input(" Input Time in Seconds: "))
prompts the user to input a time in seconds.
The value inputted is taken through the remaining steps.
Line 2: years = time // (365*24*60*60)
converts seconds into years and floor division is used to ensure that the result is an integer with noting after the decimal (no remainder).
Line 3: time = time % (365*24*60*60)
modulo division is used to get the remainder (seconds that were not converted to years) and then passes the output as the "New" time.
Line 4: day = time // (24*3600)
converts the "New" time to days and floor division is used to ensure there's noting after the decimal.
line 5: time = time % (24*3600)
modulo division is used to get the remainder (seconds that were not converted to days) and then passes the output as the "New" time.
line 6: hour = time // 3600
converts the "New" time to hours and floor division is used to ensure there's noting after the decimal.
line 7: time = time % 3600
modulo division is used to get the remainder (seconds that were not converted to hours) and then passes the output as the "New" time.
line 8: minutes = time // 60
converts the "New" time to minutes and floor division is used to ensure there's noting after the decimal.
line 9: time = time % 60
modulo division is used to get the remainder (seconds that were not converted to hours) and then passes the output as the "New" time.
line 10: seconds = time
It passes the remaining seconds to seconds
The last section of the code outputs the answer in years, days, hours minutes and seconds
print(years,"years")
print(day, "days")
print(hour, "hours")
print(minutes, "minutes")
print(seconds, "seconds")