''' ######## #8. ISBN number #As you know, every book has an unique ISBN number (International Standard Book Number). #It is a 10-digit (or 13) code that uniquely specifies a book. Since this number...




'''


########


#8. ISBN number




#As you know, every book has an unique ISBN number (International Standard Book Number).


#It is a 10-digit (or 13) code that uniquely specifies a book. Since this number is long, the right most digit is actually a "checksum"


#to roughly check if all the digits are correct (not mis-typed etc.) and forming a legit ISBN number. (checksum is also used in other places, like credit card number.)


#The rule is: when adding all the (10 numbers * its position (rightmost be position 1, leftmost be 10)) together, the sum should be divisible by 11.


#For example: ISBN 020131452-5 is legit since:


# (0*10 + 2*9 + 0*8 + 1*7 + 3*6 + 1*5 + 4*4 + 5*3 + 2*2 + 5*1)%11 = 88%11 = 0 the sum 88 is divisible by 11


#In fact, the cool thing is that the checksum (rightmost 5) is the only single digit number that can satisfy this rule. In other words, if you know the first


#9 digit, you can calculate the checksum (last digit). In this problem, you will be calculte the checksum of an ISBN number.


#########


'''


'''


Helper function 1: check_legit_ISBN


Input: a list with 10 single digit number in it


Output: return "Legit" if the 10 digits form a legit ISBN number



return "Not Legit" otherwise




Sample: [0,2,0,1,3,1,4,5,2,5] should return "Legit"



[0,2,0,1,3,1,4,5,2,3] should return "Not Legit"




'''


#def check_legit_ISBN(ISBNLis):




'''


Helper func 2: format output


input: a list with 10 numbers in it


output: format it to the correct ISBN format and return it


Sample:


[0,2,0,1,3,1,4,5,2,5] will become: "ISBN 020131452-5"


'''


#def format_ISBN(ISBNLis):




'''


Helper func 3: checksum_ISBN


Input: a list with 9 single digit number in it (first 9 digit in ISBN)


Output: print out: "The correct checksum digit is:__. Now we have a legit ISBN: _____"


Hint: just loop through 0,1,2...X (X represents 10), test every one with helper func1 to find out the one checksum that forms a legit ISBN


with the correct ISBN in lis (10 numbers), call helper func2 to format it correctly. Then print the final result.


(Technical googling practice - google how to append or remove an element from a list)


'''


#def checksum_ISBN(partISBN):






'''


Main Func: Generate a ISBN by:


add 9 random nunmbers into a list


(Technical googling practice - how to generate random numbers?)


call helper func 3 to find the checksum




Repeat 10 times


Generate 10 good ISBN numbers with one function call (not 10 digits for 1 ISBN)


Sample:


The correct checksum digit is:8. Now we have a legit ISBN:123456789-8


The correct checksum digit is:8. Now we have a legit ISBN:987654321-8


etc.


'''


#def generate_ten_ISBNs():




if __name__ == '__main__':



print("****Question 1****")



#you can add your functions calls here



#Please keep all the function calls and result printing










May 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here