forked from souravjain540/Basic-Python-Programs
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHuman_Readable_Time.py
More file actions
Latest commit
16 lines (11 loc) · 769 Bytes
/
Copy pathHuman_Readable_Time.py
File metadata and controls
16 lines (11 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
defmake_readable(seconds): #Function converts an amount of seconds into hours:minutes:seconds
seconds=int(seconds) #converts seconds into integer
hour=int(seconds/3600) #Gets hours
minute=int(seconds/60) - (hour*60) #Gets remanining minutes
second=seconds- (minute*60) - (hour*3600) #Gets remaining seconds
hour=str(hour) iflen(str(hour)) >1else'0'+str(hour) #adds 0 if the hours,minutes or seconds are only one charachter long
second=str(second) iflen(str(second)) >1else'0'+str(second)
minute=str(minute) iflen(str(minute)) >1else'0'+str(minute)
returnf"{hour}:{minute}:{second}"#returns the value
print(make_readable(input('')))
input('')