-
Notifications
You must be signed in to change notification settings - Fork 22
Barinov gosha #19
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: main
Are you sure you want to change the base?
Barinov gosha #19
Changes from all commits
0fd5aa0
4b5c354
5112bfd
362f4e5
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 @@ | ||
| ### VisualStudioCode ### | ||
| .vscode/* | ||
| !.vscode/settings.json | ||
| !.vscode/tasks.json | ||
| !.vscode/launch.json | ||
| !.vscode/extensions.json | ||
| !.vscode/*.code-snippets | ||
|
|
||
| # Local History for Visual Studio Code | ||
| .history/ | ||
|
|
||
| # Built Visual Studio Code Extensions | ||
| *.vsix | ||
|
|
||
| ### VisualStudioCode Patch ### | ||
| # Ignore all local history of files | ||
| .history | ||
| .ionide | ||
| .clang-format |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,28 @@ | ||
| def modulo11Checksum(ISBNNumber: str): | ||
|
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. Название функции и |
||
|
|
||
| digits = [int(char) for char in ISBNNumber if char.isdigit()] | ||
|
|
||
| checkDigit = digits[-1] | ||
|
|
||
| if ISBNNumber[-1] == 'x' or ISBNNumber[-1] == 'X': | ||
|
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. Если ввести |
||
| digits += [10] | ||
| total = 0 | ||
| for i in range(len(digits) - 1): | ||
| weight = 10 | ||
| if len(digits) != 10: | ||
| print("incorrect input, should be 10 numbers") | ||
| return False | ||
|
Comment on lines
+6
to
+8
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. Нужно было кидать ошибку, которая бы обрабатывалась во внешнем коде. |
||
| for i in range(10): | ||
| weight = 10 - i | ||
| digit = digits[i] | ||
| total += digit * weight | ||
| if total % 11 == 0: | ||
| print("correct") | ||
| return True | ||
| else: | ||
| print("incorrect") | ||
| return False | ||
|
Comment on lines
+13
to
+18
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. Функция |
||
|
|
||
| isbnnum = input('input your number: ') | ||
| while isbnnum != '-1': | ||
| modulo11Checksum(isbnnum) | ||
| isbnnum = input('input your number: ') | ||
|
Comment on lines
+20
to
+23
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. Когда
Comment on lines
+20
to
+23
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. Нужен блок try-except, который при ошибке уведомлял бы пользователя о сбое в работе, но программа при этом не падала. |
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| checksum = total + checkDigit | ||
| return checksum % 11 == 0 | ||
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.
Следовало добавить тесты, которые бы покрывали этот случай.