Computers and Technology
Computers and Technology, 14.11.2019 18:31, Tooey6225

Write a file named credit_card. py containing a single function, check. check accepts a single input – a positive integer. it returns true if the integer represents a valid credit card number. as with all functions that return a bool value, if it does not return true it should return false.

credit card numbers have what is called a check digit. this is a simple way of detecting common mis-typings of card numbers. the algorithm is as follows:

form a sum of every other digit, including the right-most digit; so 5490123456789128 (5490123456789128) sums to 4 + 0 + 2 + 4 + 6 + 8 + 1 + 8 = 33.

double each remaining digit, then sum all the digits that creates it; the remaining digits (5 9 1 3 5 7 9 2) in our example (5490123456789128) double to 10 18 2 6 10 14 18 4, which sums to 1+0 + 1+8 + 2 + 6 + 1+0 + 1+4 + 1+8 + 4 = 37

add the two sums above (33 + 37 = 70)

if the result is a multiple of 10 (i. e., its last digit is 0) then it was a valid credit card number.

answer
Answers: 3

Similar questions

Do you know the correct answer?
Write a file named credit_card. py containing a single function, check. check accepts a single input...

Questions in other subjects:

Konu
Mathematics, 03.09.2021 05:20