Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- """
- def ask_times():
- times = []
- inp = '1'
- while (0<len(inp)):
- print('Введите время: ', end='')
- inp = input()
- if 0<len(inp):
- times.append(inp)
- return times
- def sec_from_time(stime):
- parts = stime.split(sep=':')
- parts.reverse()
- level = 1
- ret = 0
- for part in parts:
- c = int(part)
- ret += c * level
- level *= 60
- return ret
- def time_from_sec(sec):
- parts = []
- parts.append('{:02d}'.format(sec % 60))
- d = int(sec/60)
- while(d):
- parts.append('{:02d}'.format(d % 60))
- d = int(d/60)
- parts.reverse()
- return ':'.join(parts)
- times = ask_times()
- sum_sec = sum(map(sec_from_time, times))
- sum_time = time_from_sec(sum_sec)
- print('Список: ', times)
- print('Итого: {0} / {1}'.format(sum_time, sum_sec))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement