Question: Write a PYTHON program that prompts the user to enter a credit card number... Display whether the number is valid or invalid. Credit card number

Write a PYTHON program that prompts the user to enter a credit card number... Display whether the number is valid or invalid. Credit card number must be between 13 and 16 digits Credit card number must start with o 4 for Visa o 5 for MasterCard o 37 for American Express o 6 for Discover Credit card numbers are generated following a validity check proposed by Hans Luhn of IBM in 1954. It is commonly known as the Luhn check or the Mod 10 check. Consider the card number 4388576018402626: 1. Double every second digit from right to left. If doubling of a digit results in a two-digit number, add up the two digits to get a single-digit number. 2. Now add all single-digit numbers from Step 1 a. 4 + 4 + 8 + 2 + 3 + 1 + 7 + 8 = 37 3. Add all digits in the odd places from right to left in the card number. a. 6 + 6 + 0 + 8 + 0 + 7 + 8 + 3 = 38 4. Sum the results from Steps 2 and 3. a. 37 + 38 = 75 5. If the result from Step 4 is divisible by 10, the card number is valid; otherwise, it is invalid. For example, the number4388576018402626 is invalid, but the number 4388576018410707 is valid. Design your program to use the following functions: def isValid(card_number): # Return true if the card number is valid def sumOfDoubleEvenPlace(card_number): # Get the result from Step 1 & 2 def getDigit(number): # Return this number if it is a single digit, otherwise, return the sum of the two digits def sumOfOddPlace(card_number): # Return sum of odd place digits in card number def prefixMatched(card_number, d): # Return true if the digit d is a prefix for card number (d=4,5,6, or 37) def getSize(card_number): # Return the number of digits in card_number. Print the output as follows: If the number is invalid: Your credit card number is invalid If the number is valid Your card is : Visa The number is valid

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!