-
Notifications
You must be signed in to change notification settings - Fork 50
codereview #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
codereview #54
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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)) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| """ | ||
| Вивести усі слова котрі містять в слові велику букву | ||
| """ | ||
| A=input("Введіть рядок:") | ||
| slova = A.split(" ") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
| 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) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Використовуй пробіли, набагато комфортніше читати код. |
||
| 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) | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Код написаний гарно і логічно, але в очі кидається відсутність пробілів, раджу привчати себе до них. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Код написаний гарно і коротко , але раджу не забувати про пробіли.