Question

In: Computer Science

CIS- Python (Business: check ISBN-10) An ISBN-10 (International Standard Book Number) consists of 10 digits: d1d2d3d4d5d6d7d8d9d10....

CIS- Python

(Business: check ISBN-10)

An ISBN-10 (International Standard Book Number) consists of 10 digits: d1d2d3d4d5d6d7d8d9d10. The last digit, d10, is a checksum, which is calculated from the other nine digits using the following formula:

(d1 * 1 + d2 * 2 + d3 * 3 + d4 * 4 + d5 * 5 + d6 * 6 + d7 * 7 + d8 * 8 + d9 * 9) % 11

If the checksum is 10, the last digit is denoted as X according to the ISBN-10 convention. Write a program that prompts the user to enter the first 9 digits and displays the 10-digit ISBN (including leading zeros).

Sample Run 1

Enter the first 9 digits of an ISBN as a string: 3601267

Incorrect input. It must have exact 9 digits

Sample Run 2

Enter the first 9 digits of an ISBN as a string: 013601267

The ISBN-10 number is 0136012671

Sample Run 3

Enter the first 9 digits of an ISBN as a string: 013031997

The ISBN-10 number is 013031997X

If you get a logical or runtime error, please refer https://liangpy.pearsoncmg.com/faq.html.

Solutions

Expert Solution

# Reading input
s = input("Enter the first 9 digits of an ISBN-10 as a string: ")
if(len(s)==9):
    # Initializing count to 1
    count = 0
    # looping through each digit of the input
    for i in range(1,10):
        # Counting dx*x for digit dx
        count += (i*(ord(s[i-1])-ord('0')))
    # Calculating the reminder
    count = count % 11
    # If count is less than 10 then appending reminder at the end
    if(count < 10):
        s += str(count)
    # If count is greater than or equals to 10 then appending X at the end
    else:
        s += "X"
    # Printing the final value of s
    print("The ISBN-10 number is",s)
else:
    print("Incorrect input. It must have exact 9 digits")


Related Solutions

Write an ISBN Validator in C language What are ISBN? ISBN, or International Standard Book Number,...
Write an ISBN Validator in C language What are ISBN? ISBN, or International Standard Book Number, is a numeric identifier for commercially printed books. Prior to 2007, they had 10 digits, but all newly issued ISBN use 13 digits. They are used to uniquely identify a book and consist of several portions. These include the registrant group, publisher, title, and a check digit. The registrant group indicates where the publisher is located. For example a registrant group of 0 or...
(Business: check ISBN-13) ISBN-13 is a new standard for indentifying books. It uses 13 digits d1d2d3d4d5d6d7d8d910d11d12d13...
(Business: check ISBN-13) ISBN-13 is a new standard for indentifying books. It uses 13 digits d1d2d3d4d5d6d7d8d910d11d12d13 . The last digit d13 is a checksum, which is calculated from the other digits using the following formula: 10 - (d1 + 3*d2 + d3 + 3*d4 + d5 + 3*d6 + d7 + 3*d8 + d9 + 3*d10 + d11 + 3*d12) % 10 If the checksum is 10, replace it with 0. Your program should read the input as a string....
Topic is cryptography 10.increment the digits 858 of the ISBN of the text (ISBN13: 9780890068588) to...
Topic is cryptography 10.increment the digits 858 of the ISBN of the text (ISBN13: 9780890068588) to be 859. Then, by trial and error, change the check-sum (the last digit of the ISBN), to identify the title of the next book published by Artech House.
Is 100202345X a valid ISBN number? If not, what would the correct check digit have to...
Is 100202345X a valid ISBN number? If not, what would the correct check digit have to be ? Solve the congruence 121x ≡ 5 mod 350.
Write a code in Python jupytoer note book: Ask the user to input a year. Check...
Write a code in Python jupytoer note book: Ask the user to input a year. Check if this is a leap year or not. Ask the user to input a number. Check if this number is even or odd. HbA1c of 6.5% or higher indicates diabetes. 5.7 to 6.4 indicates pre-diabetes. HbA1c less than 5.7 is considered normal. Ask the user for their HbA1c level and display if their they are in the normal range, pre-diabetic, or diabetic. Ask the...
Subject is International Business Book: Wild, J. J. & Wild, K. L. (2015). International business: The...
Subject is International Business Book: Wild, J. J. & Wild, K. L. (2015). International business: The Challenges of Globalization (8th ed.). Upper Saddle River, NJ: Prentice Hall. (ISBN 13: 978-0133866247) As the Business Development Manager for a large U.S. based telecom you have decided to explore the global market potential for your products and services. Referring to Map 12.1 in Chapter 12, select a country that you think might have potential. Write a report outlining the key items to consider...
Given n. Write a program in PYTHON to Generate all numbers with number of digits equal...
Given n. Write a program in PYTHON to Generate all numbers with number of digits equal to n, such that the digit to the right is greater than the left digit (ai+1 > ai). E.g. if n=3 (123,124,125,……129,234,…..789)
Write a Python program that reads an integer and prints how many digits the number has,...
Write a Python program that reads an integer and prints how many digits the number has, by checking whether the number is ≥10,≥100,≥1000, and so on (up to 1,000,000). Your program should also identify if a number is negative.
Python Programming Please! #Name: #Date: #Random number, loop while true #ask user for number. Check to...
Python Programming Please! #Name: #Date: #Random number, loop while true #ask user for number. Check to see if the value is a number between 1 and 10 #if number is too high or too low, tell user, if they guessed it break out of loop Display "Welcome to my Guess the number program!" random mynumber count=1 while True try Display "Guess a number between 1 and 10"   Get guess while guess<1 or guess>10 Display "Guess a number between 1 and...
Python program A number game machine consists of three rotating disks labelled with the numbers 0...
Python program A number game machine consists of three rotating disks labelled with the numbers 0 to 9 (inclusive). If certain combinations of numbers appear when the disks stop moving, the player wins the game. The player wins if the first and third numbers are the same, and the second number is less than 5, or all three numbers are the same, or the sum of the first two numbers is greater than the third number; otherwise the player loses....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT