Question: Python. need help with this. the code goes in the your solution goes here Fixed-length numbers are commonly used for identification purposes; for example, think

Python. need help with this. the code goes in the "your solution goes here"  Python. need help with this. the code goes in the "your
solution goes here" Fixed-length numbers are commonly used for identification purposes; for
example, think about bank account numbers and social security numbers. Because they

Fixed-length numbers are commonly used for identification purposes; for example, think about bank account numbers and social security numbers. Because they are so often typed in by humans, their use is sometimes error-prone. One historical way of automated validity checking of such numbers is to reserve one digit as the "check" digit, whose value is determined by a special "checksum" algorithm applied to the other digits. Part (a) in the figure below illustrates how a trailing check digit is calculated for the number 176248: it is the digit that when appended to the number in the ones place produces an augmented number whose checksum is divisible by 10. Here, the checksum algorithm involves doubling each digit whose index in the string version of the number is odd and adding the results together in the case that doubling a digit produces a two-digit result, those digits are also added. TATT oooooooo Part (b) demonstrates the validation procedure that just performs the checksum algorithm again on the augmented number. Note that it is assumed by the checksum algorithm that the trailing (or ones) digit is the check digit, so it is not doubled when added to the checksum. Note that if any one of the other digits is incorrect, the checksum fails. Thus, the check digit "3" in the ones position "validates" the number 176248. The code template below, my_checksum.py, partially defines a function do_checksum() with a single integer argument argument. The last digit of this argument is a check digit such that the checksum is expected to be divisible by 10. Your do_checksum () should return True if the number's checksum is divisible by 10, and False otherwise. The __main__block is provided to allow you to test the program on your local computer. It does not matter what you put in the __main__ block; only your do_checksum () function will be tested. def do_checksum (N): passes_checksum False Your solution goes here name return passes_checksum if main': a=728498251 # Instructor note: should not pass print('{:d} {:s) the checksum test.'.format(a, 'passes' if do_checksum (a) else 'does not pass')) a=728498254 # Instructor note: should pass print('{:d} {:s) the checksum test.'.format(a, 'passes' if do_checksum (a) else 'does not pass'))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!