FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Basic-Python-Programs/Human_Readable_Time.py at main · gitishman/Basic-Python-Programs · GitHub
gitishman
/
Basic-Python-Programs
Public
forked from
souravjain540/Basic-Python-Programs
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Basic-Python-Programs
/
Human_Readable_Time.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
16 lines (11 loc) · 769 Bytes
Breadcrumbs
Basic-Python-Programs
/
Human_Readable_Time.py
Copy path
File metadata and controls
16 lines (11 loc) · 769 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def
make_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
)
if
len
(
str
(
hour
))
>
1
else
'0'
+
str
(
hour
)
#adds 0 if the hours,minutes or seconds are only one charachter long
second
=
str
(
second
)
if
len
(
str
(
second
))
>
1
else
'0'
+
str
(
second
)
minute
=
str
(
minute
)
if
len
(
str
(
minute
))
>
1
else
'0'
+
str
(
minute
)
return
f"
{
hour
}
:
{
minute
}
:
{
second
}
"
#returns the value
print
(
make_readable
(
input
(
''
)))
input
(
''
)
Back
|
FazBrowse Home
|
New Git URL