Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- A very basic check digit example
- Pulled from a Systems Modeling Exam
- Rules are.
- User inputs two digit number where the first digit is greater than 1 (so first number being 10)
- Input is split and the sum of the two digits is the check digit, if greater than 9 the new numbers are summed together
- giving the check digit
- Examples:
- 11 = 112 (because 1 + 1 is 2)
- 76 = 764 (because 7 + 6 is 13, 1 + 3 is 4)
- '''
- num = 10
- while(num <= 99):
- num_list = list(str(num))
- sum = int(num_list[0]) + int(num_list[1])
- if(int(sum) > 9):
- c_list = list(str(sum))
- sum = int(c_list[0]) + int(c_list[1])
- print(str(num) + str(sum))
- num+=1
Add Comment
Please, Sign In to add comment