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


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