1. Engineering
  2. Computer Science
  3. checksum algorithms are used to determine whether a given number...

Question: checksum algorithms are used to determine whether a given number...

Question details

Checksum algorithms are used to determine whether a given number is valid or not. There are a variety of such algorithms. Implement a function called checksum0 which accepts a single integer value and returns True if it is value and False otherwise. The algorithm for determining validity is as follows: 1. Reverse the number and double the value of every second digit, starting with the second digit. 2 If the result of the doubling operation results in more than one digit, then replace that value with the sum of the digits of the result. 3. Calculate the sum of all the digits. 4. Check if the sum of the digits is divisible by 7. If it is, then the number is valid, otherwise it is invalid For example, if the number is 123456789 First we reverse the number 9 876 543 2 1 Then we double the value of every second digit, starting with the second digit 9 167 12 5 8 341 Then we sum the digits of any number with more than 1 digit 9773 5 8 3 4 1 Then we sum all the digits together 47 Finally, we check if 47 is evenly divisible by 7 False In a second example, the number 95 would be checked as follows: 1. Reverse the number 59 2. Double every second digit, starting with the second digit 5 18 3. Sum the digits of any number 10 5 9 4. Sum all the single digits together 14 5. Check if the number is divisible by 7 True A student who completes this exercise should be able to: Index specific elements of a list Iterate through a list Use arithmetic operators

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution