Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem B. (10 points) ISBN Check Digit The International Standard Book Number (ISBN) for a given book is a unique number allowing publishers and vendors
Problem B. (10 points) ISBN Check Digit The International Standard Book Number (ISBN) for a given book is a unique number allowing publishers and vendors to distinguish between publications, even those with the same title and/or author. The first twelve digits of an ISBN value are used to identify the region, publisher, and title of the book, while the final digit is a check digit. This means that its value is chosen based on a mathematical combination of all the other digits in the ISBN - this makes it easy to recognize when someone has mistyped one of the digits in the ISBN, because the mathematical expression used on the digits won't result in the correct value. In particular, for modern ISBN-13 numbers, the formula is as follows: (x1+3x2+x3+3x4+x5+3x6+x7+3x8+x9+3x10+x11+3x12+x13)%10=0 Where x1 represents the first digit, x2 represents the second digit, and so on. For example, the ISBN-13 of the paperback version of The Martian is 9780553418026 . If you plug the digits into the formula, the result is 0 : (9+37+8+30+5+35+3+34+1+38+0+32+6)%10(9+21+8+0+5+15+3+12+1+24+0+6+6)%10(110)%10 0 Write a function called isbn_check(isbn) that takes in one 13-character string of digits representing an ISBN-13 number. The function should return the result of the formula above as an integer (so it should return 0 for any real ISBN number, but may return a different answer if the ISBN is fake). Remember to add documentation for this function as well. Hints: - You can assume that the ISBN string passed into the function will always be a string consisting of 13 digits. - See the String Basics section in zyBooks if you're not sure how to get the individual digits out of the ISBN string. - Remember to convert each digit from a string to an integer before trying to do math on it - If you've read ahead and know what a loop is, you're permitted to use one to make this computation a little less tedious. - If the Gradescope test cases are giving you messages that involve "None" or "NoneType", you're probably using print instead of return. Examples (assumes that you're running the file in interactive mode - see the Setup section of this document if you don't remember how to do that): 0 >> isbn_check(' 9780062363602) Examples (assumes that you're running the file in interactive mode - see the Setup section of this document if you don't remember how to do that): > isbn_check (9780553418026) 0 > isbn_check (9780062363602) 0 > isbn_check (9780345391809) 6 > isbn_check (9785974718160) 2
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started