-
Notifications
You must be signed in to change notification settings - Fork 0
/
quiz_v1.py
37 lines (30 loc) · 884 Bytes
/
quiz_v1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
def time_converter():
value = int(input('Number of seconds: '))
if value < 1:
print('{} second = {} second'.format(value, value))
return
d = value // 86400
h = (value % 86400) // 3600
m = (value % 86400 % 3600) // 60
s = (value % 86400 % 3600) % 60
line = ' '
if d > 1:
line += '{} days '.format(d)
elif 0 < d < 2:
line += '{} day '.format(d)
if h > 1:
line += '{} hours '.format(h)
elif 0 < h < 2:
line += '{} hour '.format(h)
if m > 1:
line += '{} minutes '.format(m)
elif 0 < m < 2:
line += '{} minute '.format(m)
if s > 1:
line += '{} seconds '.format(s)
elif 0 < s < 2:
line += '{} second '.format(s)
line = '{} seconds ='.format(value) + line[:-1]
print(line)
if __name__ =='__main__':
time_converter()