From c881d4b2dcb3e8504dd68f09eeabea7466846105 Mon Sep 17 00:00:00 2001 From: UlianaDahnovska <55241559+UlianaDahnovska@users.noreply.github.com> Date: Mon, 23 Dec 2019 21:02:50 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=D0=94=D1=80=D1=83=D0=B3=D0=B0=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BD=D1=82=D1=80=D0=BE=D0=BB=D1=8C=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dahnovskauo/second/task1.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 dahnovskauo/second/task1.py diff --git a/dahnovskauo/second/task1.py b/dahnovskauo/second/task1.py new file mode 100644 index 0000000..dfb531a --- /dev/null +++ b/dahnovskauo/second/task1.py @@ -0,0 +1,22 @@ +''' +Користувач вводить час у форматі `hh:mm(:ss(.ms))`, де дужки позначають необов'язковість. +Напишіть функцію, що повертає кількість повних секунд, що пройшли з опівночі. +Виведіть результат. +У випадку помилкового вводу виведіть повідомлення про помилку. +''' + +import re +re_form = re.compile(r'/d/d') +def validator(pattern, promt): + text = input(promt) + while not bool(pattern.match(text)): + text = input(promt) + return text + +hours = int(validator(re_form ,'Введіть години hh:')) +min = int(validator(re_form ,'Введіть хвилини mm:')) +sec = int(validator(re_form ,'Введіть секунди(необ.) ss:')) +msec = int(validator(re_form ,'Введіть мілісекунди(необ.) ms: ')) + +time = hours*3600 + min*60 + sec + msec*0.001 +print(time) \ No newline at end of file From 409d5e2613cec26621c2a6b6bd79b3dc7ab1a177 Mon Sep 17 00:00:00 2001 From: UlianaDahnovska <55241559+UlianaDahnovska@users.noreply.github.com> Date: Mon, 23 Dec 2019 22:51:21 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D1=88=D0=B0=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BD=D1=82=D1=80=D0=BE=D0=BB=D1=8C=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dahnovskauo/first/task1.py | 5 +++++ dahnovskauo/first/task2.py | 10 ++++++++++ dahnovskauo/first/task3.py | 20 ++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 dahnovskauo/first/task1.py create mode 100644 dahnovskauo/first/task2.py create mode 100644 dahnovskauo/first/task3.py diff --git a/dahnovskauo/first/task1.py b/dahnovskauo/first/task1.py new file mode 100644 index 0000000..4055f3e --- /dev/null +++ b/dahnovskauo/first/task1.py @@ -0,0 +1,5 @@ +''' +Вивести кількість порожніх списків +''' +a = [1, 3, 'a', 123, [], 'hello', []] +print('Кількість порожніх списків:', a.count([])) \ No newline at end of file diff --git a/dahnovskauo/first/task2.py b/dahnovskauo/first/task2.py new file mode 100644 index 0000000..af98841 --- /dev/null +++ b/dahnovskauo/first/task2.py @@ -0,0 +1,10 @@ +''' +Вивести з тексту слова з великої літери +''' +text = str(input('Введіть рядок:')) +list = [] +text =text.split(" ") +for word in text: + if (i.isupper() for i in word): + list.append(word) +print(list) diff --git a/dahnovskauo/first/task3.py b/dahnovskauo/first/task3.py new file mode 100644 index 0000000..573dcf0 --- /dev/null +++ b/dahnovskauo/first/task3.py @@ -0,0 +1,20 @@ +''' +Вивести суму усіх елементів списку, що являють собою числа, та окремо вивести рядочок, який складається з усіх рядочків +''' +list = [2, 8, 'w', 'j', []] +sum = 0 +q = '' +for i in range(len(list)): + if isinstance(list[i], int): + sum = sum + list[i] + elif isinstance(list[i], str): + q = q + list[i] +' ' + else: + print('Кінець') +print('Сума:', sum) +print('Конкатенація:', q) + + + + +