Question

In Python: Write a well-documented (commented) program that asks the user for a 9-digit integer, computes...

In Python:

Write a well-documented (commented) program that asks the user for a 9-digit integer, computes its checksum, and then prints the corresponding ISBN number. The International Standard Book Number (ISBN) is a 10-digit code that uniquely specifies a book. The rightmost digit is a checksum digit that can be uniquely determined from the other 9 digits, from the condition that d1 + 2d2 +3d3 + ... + 10d10 must be a multiple of 11 (here di denotes the ith digit from the right). The checksum digit d1 can be any value from 0 to 10. The ISBN convention is to use the character X to denote 10. The checksum digit corresponding to 032149805 is 4 since 4 is the only value of x between 0 and 10 (both inclusive), for which 10·0 + 9·3 + 8·2 + 7·1 + 6·4 + 5·9 +4·8 +3·0 + 2·5 + 1·x is a multiple of 11. Sample runs would be as follows. Sample run 1: Please enter a nine digit integer: 013376940 The corresponding ISBN number would be 0133769402. Sample run 2: Please enter a nine digit integer: 013380780 The corresponding ISBN number would be 0133807800.

1 0
Add a comment Improve this question Transcribed image text
Answer #1

number=raw_input("Enter the number :")

digits = [(11 - i) * num for i, num in enumerate(map(int, list(number)))]

digit_11 = 11 - (sum(digits) % 11)

if digit_11 == 10:
    digit_11 = 'X'    
digits.append(digit_11)
isbn_number = "".join(map(str, digits))
print(isbn_number)
Add a comment
Know the answer?
Add Answer to:
In Python: Write a well-documented (commented) program that asks the user for a 9-digit integer, computes...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Python Write a well-documented (commented) program that asks the user for a 9-digit integer, computes...

    In Python Write a well-documented (commented) program that asks the user for a 9-digit integer, computes its checksum, and then prints the corresponding ISBN number. The International Standard Book Number (ISBN) is a 10-digit code that uniquely specifies a book. The rightmost digit is a checksum digit that can be uniquely determined from the other 9 digits, from the condition that d1 + 2d2 +3d3 + ... + 10d10 must be a multiple of 11 (here di denotes the ith...

  • Write a program in Python that asks the user for the ISBN of the book in...

    Write a program in Python that asks the user for the ISBN of the book in the format xxx-x-xxx-xxxxx-x. To validate: Initialize a total to 0 Have the program remove the dashes so that only the 13 digits are left in the ISBN string for each index of the first 12 digits in the 13 digit ISBN string get the digit at the current index as an integer If the current index is an even number, add the digit to...

  • Description: An ISBN-10 (International Standard Book Number) consists of 10 digits: didzdzdad5d6d7d8d9d1o. The last digit, dio,...

    Description: An ISBN-10 (International Standard Book Number) consists of 10 digits: didzdzdad5d6d7d8d9d1o. The last digit, dio, is a checksum, which is calculated from the other nine digits using the following formula: (d, x 1 + d2 x 2 +d3 x 3 + da x4 + ds x 5 + de x 6 + d7 x 7+ d3 x 8+dex 9) % 11 If the checksum is 10, the last digit is denoted as X according to the ISBN-10 convention. Write...

  • Write a program that asks the user to input a 4-digit integer and then prints the...

    Write a program that asks the user to input a 4-digit integer and then prints the integer in reverse. Your program needs to implement a function reverse that will take in as input the 4-digit number and print it out in reverse. Your code will consist of two files: main.s and reverse.s. Main.s will ask for the user input number and call the function reverse. For ARM/Data Structure needs to be able to run on Pi Reverse.s will take in...

  • Using c++ A ten diglt ISBN number uses a checksum as its last diglt to verlfy...

    Using c++ A ten diglt ISBN number uses a checksum as its last diglt to verlfy the first nine digits are valid. Before 2007, all ISBN numbers were composed like this, such as: e-20-5e8005-7 or 1-234-56789-X The first nine digits are assigned by a book's publisher and the last digit is calculated by "weighted sum (described below). The X stands for the checksum value of 10, in order to represent ten as a single digit. You must write a program...

  • IN PYTHON ''' Helper func 3: checksum_ISBN Input: a list with 9 single digit number in...

    IN PYTHON ''' 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-9, 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. '''...

  • Introduction: Ten digit ISBN numbers are created so that the first nine digits are information digits...

    Introduction: Ten digit ISBN numbers are created so that the first nine digits are information digits and the last digit is a check digit. T his last number helps people notice and correct mistakes that might be made in recording the information digits. The same is true for thirteen digit ISBN numbers. Here is a ten digit ISBN number: 0-13-149498-8. The digit 0 indicates the book is written for English-speaking people. The number 13 and the number 149498 identify the...

  • Using Python Write the following well-documented (commented) program. Create a class called Shape that has a...

    Using Python Write the following well-documented (commented) program. Create a class called Shape that has a method for printing the area and the perimeter. Create three classes (Square, Rectangle, and Circle) which inherit from it. Square will have one instance variable for the length. Rectangle will have two instance variables for the width and height. Circle will have one instance variable for the radius. The three classes will have methods for computing the area and perimeter of its corresponding shape....

  • Write a complete C++ program that do following. 1) Read a positive integer from the user...

    Write a complete C++ program that do following. 1) Read a positive integer from the user with proper prompt. Assume that this user is nice and he/she would not start the integer with digit 0. 2) Create a size 10 array as counters for digits 0 - 9. 3) Use a while loop for processing a) Single out the current last digit using modular 10 technique b) Increment the corresponding counter through the index derived in a). 4) At the...

  • the user should be prompted to enter an integer and then your program will produce another...

    the user should be prompted to enter an integer and then your program will produce another integer depending on whether the input was even or odd. The following is an example of what you might see when you run the program; the input you type is shown in green (press Enter at the end of a line), and the output generated by the program is shown in black text. Enter an integer: 1234 Number is even, taking every other digit...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT