Write a program for validating a credit card that prompts the user to enter a credit card number as a string. Display whether the number is valid or invalid. •Credit card number must be between 13 and 16 digits •Credit card number must start with: o4 for Visa o5 for MasterCard o37 for American Express o6 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 number 4388576018402626 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