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:
Code
isbn=input("Enter ISBN in following format xxx-x-xxx-xxxxx-x: ")
total=0
isbnWithoutDash=""
for ch in isbn:
if ch.isdigit():
isbnWithoutDash+=ch
lastDigit=int(isbnWithoutDash[len(isbnWithoutDash)-1])
isbnWithoutDash=isbnWithoutDash[:-1]
for ch in isbnWithoutDash:
num=int(ch)
if(num%2==0):
total+=num
else:
total+=3*num
checksum=10-(total%10)
if checksum==10:
checksum=0
if checksum==lastDigit:
print("Valid")
else:
print("Invalid")
output
code snaps
If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.
Write a program in Python that asks the user for the ISBN of the book in...
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...
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...
Using the above described algorithm, create a program that: (IN PYTHON) 1.Asks the user which type of credit card he/she would like to find the checksum for. 2. Based on the user's choice of credit card, asks the user for the n digits of the credit card. [Get the input as a string; it's easier to work with the string, so don't convert to an integer.] 3. Using the user's input of the n digits, finds the last digit of...
Please write code in
Python!
You are asked to
implement the following checksum formula to validate an identifi-
cation number given to you. The formula works as follows. Using the
original number, double the value of every other digit. Then add
the values of the individual digits together (if a doubled value
now has two digits, add the digits individually). The
identification number is valid if the resulting sum is divisible by
10. Write a function called validateID that takes...
Python 3: Write a program in python that asks the user to enter a number that contains 4 digits, i.e. in the range [1000-9999]. Your program MUST take it as a number integer. Print each digit on a separate line.
Write a python program that does the following. a. It asks the user to enter a 5-digit integer value, n. b. The program reads a value entered by the user. If the value is not in the right range, the program should terminate. c. The program calculates and stores the 5 individual digits of n. d. The program outputs a “bar code” made of 5 lines of stars that represent the digits of the number n. For example, the following...
Write a C++ program that will read in an ISBN-10 ID, and determines whether the tenth digit is the valid checksum of the first nine digits. The program reads in purported ID, and finishes execution once it has printed out what it's read in, plus either VALID or INVALID. Cannot use getline function. a) Processing stops after ten digits, even if there are more digits on the line of input. The
Script 1: Sum of Numbers Write a python program that asks the user to enter a series of single-digit numbers with nothing separating them. The program should display the sum of all the single digit numbers in the string. For example, if the user enters 2514, the method should return 12, which is the sum of 2, 5, 1, and 4.
Write a program in Python to solve the following task: In this project, you will build a phone number from digits entered by your user. Your program will loop until 10 valid digits have been entered. It will then use those digits to display the phone number entered using the format: XXXXXXXXXX (or (XXX) XXX – XXXX for extra credit). The program will ask for a digit, it will check to see if the digit is actually between 0 and...
Write a C++ program that asks for the following information about a book order from the console: • Title • Author • ISBN (hint: careful about what data type to use - validate 9 or 13 characters) • Price (validate number < 400) • Quantity (number of books to purchase – validate > 0 and < 100) • Fiction/Non-Fiction (‘N’ or ‘F’ - validate) • Genre (‘R’ romance, ‘D’ drama, ‘M’ mystery – validate) Make use of the following data...