Guest User

Untitled

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