-
Notifications
You must be signed in to change notification settings - Fork 51
ready_to_review #59
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?
ready_to_review #59
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,19 @@ | ||
| import re | ||
| ''' | ||
| Створити регулярний вираз, що буде перевіряти, чи правильно записана конструкція besin-writeln()-end. У цій послідовності | ||
| слід дотримуватися наступних правил: всередині begin може розташовуватись максимум ще одна кострукція, що починається з | ||
| begin. Очевидно, що кількість слів end має бути аналогічною. При цьому кількість вкладень writeln() не обмежуэться. Весь | ||
| вираз записується без використання пробільних символів | ||
| ''' | ||
|
|
||
| def res_func(str_1): | ||
|
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. Для кращої читабельності коду функції варто назвати validator |
||
| """checking the input string""" | ||
| if bool(re.match('^[begin ]{1,2}[writeln() ]+[end]{1,2}$', str_1)): | ||
|
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. Регулярний вираз не коректний для даної задачі, потрібно замінити на (^(begin begin)(( begin)( readln()| writeln())( begin){0,1}( end){0,1}( readln()| writeln())( end))*$) |
||
| print('YES') | ||
| else: | ||
| print('NO') | ||
|
Comment on lines
+12
to
+14
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. Краще повертати змінну типу bool , для підвищення універсальності функції. |
||
|
|
||
|
|
||
| in_string = input('Введіть рядок: ') | ||
|
|
||
| res_func(in_string) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| ''' | ||
| Дано список, що включає в себе елементи різних типів. визначити кількість пустих вкладених списків, що містяться у цьому | ||
| початковому списку. | ||
| ''' | ||
|
|
||
| list_1 = ['jdsf', 'jkldsf', 174268, 325, True, [], '12', []] | ||
|
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. Варто список назвати main_list |
||
|
|
||
| print(list_1.count([])) | ||
|
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,11 @@ | ||
| """ | ||
| Дано довільний рядок, що є реченням. Вивести кожне 3 слово в цьому реченні. | ||
| """ | ||
|
|
||
| text_1 = 'Найбілишим містом України і одночасно столицею країни є Київ' | ||
|
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. Назву text_1 варто замінити на line для більшї читабельності коду |
||
| list_sentence = text_1.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. Не зовсім зрозуміла назва list_sentence, краще замінити на list_word |
||
| if len(list_sentence) < 3: | ||
| print('Введене вами речення містить менше 3 слів') | ||
| else: | ||
| for word in list_sentence[::3]: | ||
| print(word) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| ''' | ||
| Користувач вводить 2 цілих числа. Вивести на екран усі числа, що містяться між визначиними числами(тобто, не включаючи | ||
| їх). | ||
| ''' | ||
|
|
||
| num_1 = int(input('Пепрше число: ')) | ||
| num_2 = int(input('Друге число: ')) | ||
|
Comment on lines
+6
to
+7
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. Немає перевірки на тип данних, які вводяться з клавіатури, що може призвести до помилки ValueError |
||
|
|
||
| for number in range(num_1+1, num_2): | ||
| print(number) | ||
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.
Недоречно імпортувати цілу бібліотеку, краще замінити на from re import match