Skip to content

Commit 72c3b0f

Browse files
committed
Changed program into python file
1 parent 4498cca commit 72c3b0f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Human_Readable_Time.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
def make_readable(seconds): #Function converts an amount of seconds into hours:minutes:seconds
2+
3+
seconds = int(seconds) #converts seconds into integer
4+
5+
hour = int(seconds/3600) #Gets hours
6+
minute = int(seconds/60) - (hour*60) #Gets remanining minutes
7+
second = seconds - (minute*60) - (hour*3600) #Gets remaining seconds
8+
9+
hour = str(hour) if len(str(hour)) > 1 else '0' + str(hour) #adds 0 if the hours,minutes or seconds are only one charachter long
10+
second = str(second) if len(str(second)) > 1 else '0' + str(second)
11+
minute = str(minute) if len(str(minute)) > 1 else '0' + str(minute)
12+
13+
return f"{hour}:{minute}:{second}" #returns the value
14+
15+
print(make_readable(input('')))

0 commit comments

Comments
 (0)