Skip to content

Comments

Торгова Дарья Б42#21

Open
cutenti wants to merge 10 commits intopython-course-matmex:mainfrom
cutenti:cutenti-patch-1
Open

Торгова Дарья Б42#21
cutenti wants to merge 10 commits intopython-course-matmex:mainfrom
cutenti:cutenti-patch-1

Conversation

@cutenti
Copy link

@cutenti cutenti commented Nov 7, 2025

Сделан форк и добавлены недостающие файлы
Исправлены баги в файлах
Добавлены тесты
Реализована утилита

Вес каждого элемента теперь убывает, а последний элемент умножается на свой вес.
Теперь мы учитываем случай, когда left == right.
Добавили хорошую проверку с Х и плохую проверку с 9 цифрами
Вводим номер и проверяем на корректность.
Добавили в функции проверку на правильность формата номера.
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
Бинарный поиск: 4/5
Оформление: 8/10 (snake_case)

Comment on lines +4 to +5
if len(ISBNNumber) == 13 and ISBNNumber.count('-') == 3:
if ISBNNumber[1] == '-' and ISBNNumber[-2] == '-':
Copy link

Choose a reason for hiding this comment

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

ISBN бывают разные, например 9971-5-0210-0.

Comment on lines +9 to +10
elif char.upper() == 'X':
digits.append(10)
Copy link

Choose a reason for hiding this comment

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

Такая проверка позволит символу X стоять в любом месте кода, тогда как он может находится только на последней позиции.

total += digit * weight

checksum = total + checkDigit
checksum = total + checkDigit * (weight - 1)
Copy link

Choose a reason for hiding this comment

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

Это работает случайно, только лишь потому что weight после цикла остается равной 2. При этом в умножении на (weight - 1) нет никакой необходимости.

def binSearch(xs: list[int], x: int):
left, right = 0, len(xs) - 1
while left < right:
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.

Нет теста, который бы показывал что баг исправлен.



def test_good2():
assert modulo11Checksum("2-22X-11156-8")
Copy link

Choose a reason for hiding this comment

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

  • контрольная цифра (от 0 до 10: арабская от 0 до 9 и римская X — для 10)

ISBN10

Comment on lines +26 to +33
ISBNNumber = input("Введите исбн номер: ")
while ISBNNumber != "-1":
result = modulo11Checksum(ISBNNumber)
if result == 1:
print("correct")
else:
print("incorrect")
ISBNNumber = input("Введите исбн номер: ")
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__".

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