# IT Genius' Help Needed

Announcements
#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())

d6 = int(input())

d7 = int(input())

d8 = int(input())

d9 = int(input())

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
5 years ago
#2
It works fine for me?
0
#3
(Original post by s4b3rt00th)
It works fine for me?
Does it print out the check digit?
0
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
#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
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
#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
X

new posts Back
to top
Latest

### Oops, nobody has postedin the last few hours.

Why not re-start the conversation?

see more

### Poll

Join the discussion

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%
18.18%
Learning about/speaking to Student Finance England (2)
6.06%
Something else (tell us in the thread) (2)
6.06%