Skip to content

Comments

Barinov gosha#19

Open
Gosha924 wants to merge 4 commits intopython-course-matmex:mainfrom
Gosha924:barinovGosha
Open

Barinov gosha#19
Gosha924 wants to merge 4 commits intopython-course-matmex:mainfrom
Gosha924:barinovGosha

Conversation

@Gosha924
Copy link

@Gosha924 Gosha924 commented Nov 7, 2025

No description provided.

Barinov Gosha added 4 commits November 7, 2025 16:21
…ектный тест(теперь этот тест возвращает тру когда результат работы программы correct) 2) добавил тест который проверяет что последнее число может быть 10
Copy link

@Godrik0 Godrik0 left a comment

Choose a reason for hiding this comment

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

ISBN10: 7/10
Бинарный поиск: 3/5
Оформление: 5/10 (нет лицензии, не исправлен стиль, нет никакого описания к PR)

Comment on lines +20 to +23
isbnnum = input('input your number: ')
while isbnnum != '-1':
modulo11Checksum(isbnnum)
isbnnum = input('input your number: ')
Copy link

Choose a reason for hiding this comment

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

Когда pytest импортирует этот файл для тестов, он зависнет, ожидая ввода данных.
Код, который относится к запуску нужно оборачивать в if __name__ == "__main__".

Comment on lines +13 to +18
if total % 11 == 0:
print("correct")
return True
else:
print("incorrect")
return False
Copy link

Choose a reason for hiding this comment

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

Функция modulo11Checksum должна лишь возвращать True/False, добавление вывода в консоль загрязняет её. Вывод в консоль или другие, не относящиеся к сути функции действия, должны происходить в вызывающем коде. Сейчас, если мы захотим использовать ее в if у нас будет мусорный вывод в консоль.

@@ -1,14 +1,28 @@
def modulo11Checksum(ISBNNumber: str):
Copy link

Choose a reason for hiding this comment

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

Название функции и ISBNNumber не соответствует snake_case.


checkDigit = digits[-1]

if ISBNNumber[-1] == 'x' or ISBNNumber[-1] == 'X':
Copy link

Choose a reason for hiding this comment

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

Если ввести "", то всё упадет с ошибкой IndexError: string index out of range.

while left < right:
if not isinstance(x, int):
raise TypeError(f'X must be int, but {type(x)}')
while left <= right:
Copy link

Choose a reason for hiding this comment

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

Следовало добавить тесты, которые бы покрывали этот случай.

Comment on lines +6 to +8
if len(digits) != 10:
print("incorrect input, should be 10 numbers")
return False
Copy link

Choose a reason for hiding this comment

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

Нужно было кидать ошибку, которая бы обрабатывалась во внешнем коде.

Comment on lines +20 to +23
isbnnum = input('input your number: ')
while isbnnum != '-1':
modulo11Checksum(isbnnum)
isbnnum = input('input your number: ')
Copy link

Choose a reason for hiding this comment

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

Нужен блок try-except, который при ошибке уведомлял бы пользователя о сбое в работе, но программа при этом не падала.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants