top of page
Writer's pictureThe Tech Platform

Python program to Convert Hours to Seconds



Convert Hours to Seconds

In this program, we need to multiply hours with 60 (1 hour = 60 minutes ) so that we get in minutes, and once we get minutes we need to multiply with 60 ( 1 minute = 60 seconds) so that we get in seconds

hours = int(input("Please enter hours:"))
seconds = hours * 60 * 60
print(seconds, " Seconds")

Output:



Convert Days, Hours, Minutes and Seconds

days = int(input("Please enter days :- ")) * 3600 * 24
hours = int(input("Please enter hours :- ")) * 3600
minutes = int(input("Please enter minutes :- ")) * 60
seconds = int(input("Please enter seconds :- "))
time = days + hours + minutes + seconds
print("The  Total seconds :- ", time)

Output:



The Tech Platform

Recent Posts

See All

Comments


bottom of page