How to convert seconds to minutes, hours , days and years
Maybe sometimes, you think how about to covert a sum of seconds into minutes, hours , days and years . while I'm learning Python programming language , I wrote a code that converts the seconds
this is the code.
# this is a program that converts a total number of seconds
# to years, days, hours, minutes and remining seconds
# the code is totally written by : hakim
print("This program helps you to convert Seconds to Years , Days , Hours and Minutes " )
while True:
total_second = int(input("Enter the total number of seconds:"))
total_min = total_second / 60
sec_remainder = total_second % 60
total_hour = total_min / 60
min_remainder = total_min % 60
total_day = total_hour / 24
hour_remainder = total_hour % 24
total_year = total_day / 365
day_remainder = total_day % 365
print("**********THE FINAL RESULT IS************")
if (total_second > 1000000000000000 and total_second <=9999999999999999 (sad)
print(" The number you entered is a Quadrillion ")
elif ( total_second < 1000000000000000 and total_second >= 1000000000000):
print(" The number you entered is a Trillion ".upper())
if (total_year < float(1)):
print(total_second , " seconds are : " , int(day_remainder) , " days, " , int(hour_remainder) , " hour(s) " , int(min_remainder) ,
"minutes and" , int(sec_remainder), " seconds")
else:
print(total_second , " seconds are : " , int(total_year) , " year(s) ," , int(day_remainder) , " days, " , int(hour_remainder) , " hour(s) " , int(min_remainder) ,
"minutes and" , int(sec_remainder) , " seconds")
Comments
Post a Comment