Thursday, 19 September 2024

Practical - 66 - Write a program in python to input number of seconds and print it in the form: hrs:mins:sec. e.g. 4815 seconds are printed as 1 hrs:20 mins:15 secs

Practical - 66 - Write a program in python to input number of seconds and print it in the form: hrs:mins:sec. e.g. 4815 seconds are printed as 1 hrs:20 mins:15 secs


Ans:

n=int(input("Enter number of seconds = "))

hrs=n//3600

n=n-hrs*3600

mins=n//60

sec=n-mins*60

print(hrs,"hrs:",mins,"mins:",sec,"sec")

 

Output:

Enter number of seconds = 4815

1 hrs: 20 mins: 15 sec


No comments:

Post a Comment