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...
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)
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...
homework check please =) A distribution has a standard deviation of σ = 10. Find the...
homework check please =) A distribution has a standard deviation of σ = 10. Find the z-score for each of the following locations in the distribution. Above the mean by 5 points. Answer: ___.5___________ Above the mean by 2 points. Answer: ______.2___________ Below the mean by 20 points. Answer: ______-2__________ Below the mean by 15 points. Answer: ________-1.5_______ For a distribution with a standard deviation of σ = 20, describe the location of each of the following z-scores in terms...
Part1. Create a number guessing game in Python. Randomly generate a number from 1 to 10....
Part1. Create a number guessing game in Python. Randomly generate a number from 1 to 10. Have the user guess the number. If it is too high, tell the user to guess lower - it it is too low, tell the user to guess higher. Continue until she guesses the correct number. - Part 2. Allow the user to play a new game after they have guessed correctly.   Part 3. Ask for a different name and keep track of how...
PYTHON: Write a program that asks the user to enter a 10-character telephone number in the...
PYTHON: Write a program that asks the user to enter a 10-character telephone number in the format XXX-XXX-XXXX. The application should display the telephone number with any alphabetic characters that appeared in the original translated to their numeric equivalent. For example, if the user enters 555-GET-FOOD, the application should display 555-438-3663. This is my code, but I cannot figure out where to go from here. #set new number new_number = "" #split number split_num = phone.split("-") for char in split_num[1:2]:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT