Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions chukhbv/first/Task1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
Вивести усі порожні списки з поданого списку
"""

list=[1,3,555,[],134,'fjwlijc',[],'random']
LS=list.count([])
print("Кількість порожніх списків="+str(LS))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Код написаний гарно і коротко , але раджу не забувати про пробіли.

14 changes: 14 additions & 0 deletions chukhbv/first/Task2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
Вивести усі слова котрі містять в слові велику букву
"""
A=input("Введіть рядок:")
slova = A.split(" ")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"A" , це не коректне ім'я для змінної.

list=[]
slovo=0
bukwa=0
for slovo in slova:
for bukwa in slovo:
if (bukwa.isupper()):
list.append(slovo)
break
print(list)
10 changes: 10 additions & 0 deletions chukhbv/first/Task3.py
Original file line number Diff line number Diff line change
@@ -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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Використовуй пробіли, набагато комфортніше читати код.

19 changes: 19 additions & 0 deletions chukhbv/second/task1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""
Вивести з рядка всі числа та конвертувати їх з двійкової системи в 16-кову
"""
import re
s=input()
a=re.findall(r'\d+',s)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Для початку, треба давати гарні ім'я для змінних, оскільки це спрощує читання коду s краще замінити хоча б на string.По-друге, краще створювати окрему змінну для шаблону і знову ж загально прийнятим ім'ям для шаблону є pattern, рекомендую використовувати його.

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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Код написаний гарно і логічно, але в очі кидається відсутність пробілів, раджу привчати себе до них.