IT Genius' Help Needed

Watch this thread
Oppaisenpai
Badges: 0
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#1
Report Thread starter 5 years ago
#1
I'm trying to write a script to ask the user for a 10 digit ISBN.
The program should then print out the check digit.
The check digit is calculated as follows:
-First digit x 11 + Second digit x 10 +...+Last digit x 2
-The answer is then divided by 11 and the remainder is kept
-Then the answer is taken away from 11 which is then the check digit


This is what I have so far.....
_________________________________________________________________
import math

def isbncheck(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10):
isbn=(((d1 * 11) + (d2 * 10) + (d3 * 9) + (d4 * 8) + (d5 * 7) + (d6 * 6) + (d7 * 5) + (d8 * 4) + (d9 * 3) + (d10 * 2)) / 11) - 11
return isbn


print ("Please type the first digit:")
d1 = int(input())

print ("Please type the second digit:")
d2 = int(input())

print ("Please type the third digit:")
d3 = int(input())

print ("Please type the fourth digit:")
d4 = int(input())

print ("Please type the fifth digit:")
d5 = int(input())

print ("Please type sixth digit:")
d6 = int(input())

print ("Please type seventh digit:")
d7 = int(input())

print ("Please type eighth digit:")
d8 = int(input())

print ("Please type ninth digit:")
d9 = int(input())

print ("Please type tenth digit:")
d10 = int(input())

isbn = isbncheck(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10)
print (isbn)
_________________________________________________________________
I really don't know why it is not working... Any help would be appreciated.
0
reply
s4b3rt00th
Badges: 11
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#2
Report 5 years ago
#2
It works fine for me?
0
reply
Oppaisenpai
Badges: 0
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#3
Report Thread starter 5 years ago
#3
(Original post by s4b3rt00th)
It works fine for me?
Does it print out the check digit?
0
reply
s4b3rt00th
Badges: 11
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#4
Report 5 years ago
#4
It prints out the "isbn" variable. If I input 1, 2, 3, 4, 5... 10, it prints out 14.0, which I believe is what it should print out.

What should it print out? Do you have any errors being handed out?
0
reply
Oppaisenpai
Badges: 0
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#5
Report Thread starter 5 years ago
#5
(Original post by s4b3rt00th)
It prints out the "isbn" variable. If I input 1, 2, 3, 4, 5... 10, it prints out 14.0, which I believe is what it should print out.

What should it print out? Do you have any errors being handed out?
No I don't have any errors being handed out but it is supposed to print out the check digit after all the calculations and it is not doing so.
0
reply
s4b3rt00th
Badges: 11
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#6
Report 5 years ago
#6
Code:
isbn = isbncheck(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10)
print (isbn)
Line 1. I don't think you understand what these lines do. "isbn" is a variable, which stores the outcome of the calculations you've asked the function "isbncheck" to do.

Line 2. It then prints the variable "isbn", which is the "check digit" you're on about.

---

Input the numbers and see the result. Now get a calculator and check if the result is correct. You'll realise that the outcome is exactly what you want.
0
reply
Oppaisenpai
Badges: 0
Rep:
? You'll earn badges for being active around the site. Rep gems come when your posts are rated by other community members.
#7
Report Thread starter 5 years ago
#7
(Original post by s4b3rt00th)
Code:
isbn = isbncheck(d1, d2, d3, d4, d5, d6, d7, d8, d9, d10)
print (isbn)
Line 1. I don't think you understand what these lines do. "isbn" is a variable, which stores the outcome of the calculations you've asked the function "isbncheck" to do.

Line 2. It then prints the variable "isbn", which is the "check digit" you're on about.

---

Input the numbers and see the result. Now get a calculator and check if the result is correct. You'll realise that the outcome is exactly what you want.
Don't worry about it man i figured it out. Thanks anyway!
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest

How did The Student Room help you with your university application?

Talking to current university students (8)
24.24%
Talking to peers going through the same thing (10)
30.3%
Speaking to student ambassadors from the universities (2)
6.06%
Speaking to staff members from universities (0)
0%
Using the personal statement builder, library or helper service (3)
9.09%
Reading articles about what steps to take (6)
18.18%
Learning about/speaking to Student Finance England (2)
6.06%
Something else (tell us in the thread) (2)
6.06%

Watched Threads

View All