Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Introduction to python, Could answer it as editable code please 9. Suppose you t

ID: 2293947 • Letter: I

Question



Introduction to python, Could answer it as editable code please 9. Suppose you type a 14-digit credit card number into a Web site, but mistype one of the digits or inadvertently interchange two adjacent digits. The Web site will perform a validation check that always detects the first type of errors and nearly always detects the second type of error. The validation check is as follows: a. Starting with the leftmost bit, double it and then double every other digit after it. However, if any of the doubled digits is a two-digit number, subtract 9 from it. Then sum these new digits. For instance, if the credit card number is 58667936100244, then the digits considered are 5,6,7,3,1,0,4, their new replacements are 1,3,5,6,2,0,8, and the sum of the replacements is 25. b. Sum together the remaining seven digits from the credit card number. That is, the digits in the odd-numbered positions. With the credit card number above we obtain 8+6+9+6+0+2+4-35 c. Add together the two sums. If the result is multiple of 10, then accept the credit card number. Otherwise, reject it. We accept the credit card number above since 25+35 60, a multiple of 10. Write a program that performs data validation on a credit card number. Enter a credit card number: 58667936100244 The number is valid.

Explanation / Answer

python code:

num = input("Enter credit card number:")
sume = 0
sumo = 0
for i in range(len(num)):
if i % 2 == 0:
n = 2 * int(num[i])
if n > 9:
sume = sume + n - 9
else:
sume = sume + n
if i % 2 != 0:
sumo = sumo + int(num[i])
n =sume + sumo
if n % 10 == 0:
print("The number is valid")
else:
print("The numbet is invalid")

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote