Skip to content

Comments

control work#5

Open
Ilya-Bugaev wants to merge 12 commits intopython-course-matmex:mainfrom
Ilya-Bugaev:main
Open

control work#5
Ilya-Bugaev wants to merge 12 commits intopython-course-matmex:mainfrom
Ilya-Bugaev:main

Conversation

@Ilya-Bugaev
Copy link

Фамилия, имя: Бугаев Илья
Группа: 25.Б-42

В ходе работы были исправлены баги в src/checksum.py и src/bin_search.py.
Добавлены необходимые unit-тесты

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: 5/10
Бинарный поиск: 5/5
Оформление: 7/10 (не добавлен .gitignore, лицензия, __pycache__ в PR)

Comment on lines +21 to +28
while True:
isbn = input("ISBN: ").strip()
if isbn == "-1":
break
if check_isbn(isbn):
print("correct")
else:
print("incorrect")
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__".

def modulo11_checksum(is_bn_number: str):

digits = [int(char) for char in ISBNNumber if char.isdigit()]
if not isbn_number or not isinstance(isbn_number, str):
Copy link

Choose a reason for hiding this comment

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

Ошибка в isbn_number, в функции аргумент назывался is_bn_number.

Comment on lines +17 to +18
checksum = total % 11
return checksum == check_digit
Copy link

Choose a reason for hiding this comment

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

Ошибка в логике.
Нужно было либо оставить checksum = total + checkDigit и сравнивать остаток от деления на 11 с 0.
Либо высчитывать вот так (11 - (sum % 11)) % 11 и тогда уже сравнивать с контрольной цифрой.

Comment on lines +7 to 15
digits = [int(char) for char in is_bn_number if char.isdigit()]

check_digit = digits[-1]

total = 0
for i in range(len(digits) - 1):
weight = 10
weight = 10 - i
digit = digits[i]
total += digit * weight
Copy link

Choose a reason for hiding this comment

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

У Вас пропущена обработка символа X, который может служить контрольной цифрой.

Comment on lines +21 to +28
while True:
isbn = input("ISBN: ").strip()
if isbn == "-1":
break
if check_isbn(isbn):
print("correct")
else:
print("incorrect")
Copy link

Choose a reason for hiding this comment

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

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

isbn = input("ISBN: ").strip()
if isbn == "-1":
break
if check_isbn(isbn):
Copy link

Choose a reason for hiding this comment

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

У Вас функция называется modulo11_checksum.

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