Skip to content

Commit c383860

Browse files
Merge pull request #4 from Jolinator/main
Human Readable Time
2 parents 7e4e2c4 + 4363710 commit c383860

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Human_Readable_Time.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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('')))
16+
input('')

0 commit comments

Comments
 (0)