CS 170 Lab 8: ISBN Numbers

This is a lab exercise that involves using loops and strings.

Important: This lab will allow you the opportunity to explore pair programming which just means two students working on the same program at the same time at the same computer. You take turns typing and both offer ideas about what you should try next. If you choose to do this, please upload one (1) copy of the program with both of your names prominently displayed in it.

ISBN-10 numbers are ten character strings that uniquely identify an edition of a book. The first nine characters are base 10 digits. The last character (the tenth) is an encoding that is a function of the first nine digits. Your program is going to do various things with ISBN-10 numbers.

Notes: There are other formulas for calculating ISBN-10 check digits, but I insist that you use the one described here. Also, there is a newer ISBN system known as ISBN-13 that you should ignore completely for our purposes.

  1. Open the Python file isbnTest.py and save it to your Y: drive. Your assignment is to write the code that this file describes, meaning completing the main function and implementing the calc10 function. The calc10 function takes a string representation of an ISBN-10 number and calculates the correct tenth digit of the number. One formula for calculating the check (tenth) digit of an ISBN-10 number is (1d0 + 2d1 + 3d2 + ... + 9d8) mod 11. Notice that the input should contain 10 digits, but you only use the first 9 of them to calculate the check digit. In a correct ISBN-10 number, this result becomes the tenth digit of the number. Note that the input from the user might or might not have a correct check digit. Note that mod 11 can result in numbers as large as 10. If the result is 10, "X" is the correct value for the tenth digit. Your function should return the correct tenth digit as a string.

  2. For example, given the ISBN-10 number "0596002813" your calc10 function should return "5" and your main program should report that the given value was "3", but actual value should have been "5". Given the ISBN-10 number "013611167X" your calc10 function should return "X" and your main program should report that the given and actual values were both "X".

  3. When your program is working properly you should upload it. Make sure your file has your name (both names if doing pair programming) and Lab 08 prominently displayed on it.