Question: A function is a mini-program that we can write separately from the main program, without having to think about the rest of the program while


A function is a mini-program that we can write separately from the main program, without having to think about the rest of the program while we write it. This allows us to reduce a complicated program into smaller, more manageable chunks, which reduces the overall complexity of our program. Write a program to validate a credit card number. Create all the functions listed below and implement them within your program. (Financial: credit card number validation) Credit card numbers follow certain patterns: It must have between 13 and 16 digits, and the number must start with: 4 for Visa cards 5 for MasterCard credit cards 37 for American Express cards 6 for Discover cards 2. Now add all single-digit numbers from Step 1 . 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. 6+6+0+8+0+7+8+3=38 4. Sum the results from Steps 2 and 3. 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. \# Return true if the card number is valid def isvalid(number): \# Get the resu7t from Step 2 def sumOfDoubleEvenPlace(number): \# Return this number if it is a single digit, otherwise, return \# the sum of the two digits def getDigit(number): \# Return sum of odd place digits in number def sum0fOddPlace(number): \# Return true if the digit d is a prefix for number def prefixMatched (number, d): \# Return the number of digits in d def getSize (d): \# Return the first k number of digits from number. If the \# number of digits in number is less than k, return number. def getPrefix(number, k)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
