Programming Examples

Python program to input the time in second and convert into hours minute and seconds


convert seconds to hour minute and seconds

Write a python code to input the time in seconds. Display the time after converting it into hours, minutes and seconds.

Sample Output: Time in Second 5420

Sample Output: 1 Hour 30 Minutes 20 Seconds

Solution 1:

sec=int(input("Enter time in Second : "))
hour=sec//3600
rem=sec%3600
min=rem//60
sec=rem%60
print(hour," hour ",min," minute and ",sec," second")

Solution 2:

sec=int(input("Enter time in Second : "))
hour=sec//3600
min=(sec%3600)//60
sec=(sec%3600)%60
print(hour," hour ",min," minute and ",sec," second")
Output/ Explanation:


Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad