From 237e96d1554356b32329fbee5ca68065467abcfd Mon Sep 17 00:00:00 2001 From: Chukh Bohdan Date: Mon, 23 Dec 2019 22:05:12 +0200 Subject: [PATCH] Tasks from control works for review --- chukhbv/first/Task1.py | 7 +++++++ chukhbv/first/Task2.py | 14 ++++++++++++++ chukhbv/first/Task3.py | 10 ++++++++++ chukhbv/second/task1.py | 19 +++++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 chukhbv/first/Task1.py create mode 100644 chukhbv/first/Task2.py create mode 100644 chukhbv/first/Task3.py create mode 100644 chukhbv/second/task1.py diff --git a/chukhbv/first/Task1.py b/chukhbv/first/Task1.py new file mode 100644 index 0000000..7b93ede --- /dev/null +++ b/chukhbv/first/Task1.py @@ -0,0 +1,7 @@ +""" +Вивести усі порожні списки з поданого списку +""" + +list=[1,3,555,[],134,'fjwlijc',[],'random'] +LS=list.count([]) +print("Кількість порожніх списків="+str(LS)) \ No newline at end of file diff --git a/chukhbv/first/Task2.py b/chukhbv/first/Task2.py new file mode 100644 index 0000000..ea22e74 --- /dev/null +++ b/chukhbv/first/Task2.py @@ -0,0 +1,14 @@ +""" +Вивести усі слова котрі містять в слові велику букву +""" +A=input("Введіть рядок:") +slova = A.split(" ") +list=[] +slovo=0 +bukwa=0 +for slovo in slova: + for bukwa in slovo: + if (bukwa.isupper()): + list.append(slovo) + break +print(list) \ No newline at end of file diff --git a/chukhbv/first/Task3.py b/chukhbv/first/Task3.py new file mode 100644 index 0000000..0637304 --- /dev/null +++ b/chukhbv/first/Task3.py @@ -0,0 +1,10 @@ +""" +Порахувати суму САМЕ чисел в списку +""" +list=[1,2,555,241,7777,[],'slovo','hvatit',999129,[]] +print(list) +sum=0 +for i in list: + if isinstance(i,int): + sum+=i +print(sum) \ No newline at end of file diff --git a/chukhbv/second/task1.py b/chukhbv/second/task1.py new file mode 100644 index 0000000..ff6949a --- /dev/null +++ b/chukhbv/second/task1.py @@ -0,0 +1,19 @@ +""" +Вивести з рядка всі числа та конвертувати їх з двійкової системи в 16-кову +""" +import re +s=input() +a=re.findall(r'\d+',s) + +print(a) +def convert_base(num): + alpabet =['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'] + n=int(num) + if n<16: + return alpabet[n] + else: + return convert_base(n//16)+alpabet[n%16] + +for i in a: + c=convert_base(i) + print(c) \ No newline at end of file