Skip to content

added solution m1/005 #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions projects/005-units-of-time-again/python/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

day_sec = 86400
hours_sec = 3600
minutes_sec = 60
# i = 2

# user input

n_seconds = int(input("Insert a number of seconds:"))

# calculation Day

n_day = n_seconds // day_sec
n_seconds = n_seconds % day_sec

# calculation Hours

n_hours = n_seconds // hours_sec
n_seconds = n_seconds % hours_sec

# calculation Minutes

n_minutes = n_seconds // minutes_sec
n_seconds = n_seconds % minutes_sec


print(f'{n_day}:{n_hours:02}:{n_minutes:02}:{n_seconds:02}') # f-string ":02" indica il numero di digits totali mettendo uno zero davanti ai numeri con cifra singola
# ALTERNATIVA: print(f'{(int(n_day))}:{int(n_hours):0{i}}:{int(n_minutes):0{i}}:{int(n_seconds):0{i}}')