Tuesday, July 30, 2019

Enhanced time seconds converter in HH:MM:SS format

Script

#!/usr/local/bin/python3.7

seconds = int(input('Please enter the number of seconds: '))

hours = seconds // 3600

seconds = seconds % 3600

minutes = seconds // 60

seconds = seconds % 60

print(hours, ":", sep = "", end = "")

tens = minutes // 10

ones = minutes % 10

print(tens, ones, ":", sep = "", end = "")

tens = seconds // 10

ones = seconds % 10

print(tens, ones, sep = "")


Execution

Please enter the number of seconds: 5321
1:28:41


Please enter the number of seconds: 9857
2:44:17








No comments:

Post a Comment