Created
June 21, 2018 04:49
-
-
Save BlaneyXYZ/5380bb0e842b6a6cc5a6a450c3d07645 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment