Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# Question 1 (4 parts). ISBN number #As you know, every book has an unique ISBN number (International Standard Book Number). #It is a 10-digit

# Question 1 (4 parts). 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 # PART 1

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 # PART 2

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 # PART 3

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: # PART $

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():

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions