Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

please help me with this exercise You need to design a python program to validate a Visa credit card number. This number is stored in

please help me with this exercise
image text in transcribed
image text in transcribed
You need to design a python program to validate a Visa credit card number. This number is stored in a list. Validation goes through three steps: 1. Validate the length of the list the card number must have exactly 16 digits. 2. Validate the beginaing of the number: Visa cards begin with 4. 3. Apply the Check algorithm (see below) to validate the number. In mathematies. Check's formula is used for its applications in cryptology. It is a simple checksum formula used to validate a variety of account nambers, such as credit card numbers, Canadian social insarance numbers, etc. Description The algorithm proceeds in three steps. 1. The algorithm doables every second digit, starting with the second to last and moving from right to left. If twice a digit is greater than nise (for cumple 28=16 ), then it must be redaced to a digit between 1 and 9 by taking its remainder in the Eucludean division by 9 . To do this, we subtract 9 at dooble. Using the same example. 169=7. 2. The sum of all the digits obtaibed is carried out. 3. The resalt is divided by 10 . If the remainder of the division is zere, then the original number is valid. Example Consider the identification of the number 972-487-086. The first step is to double cvery oeher digit starting from the penultimate to the begianing, and to add up all the digibs doubled or not (if a digit is greater than 9 . suberact 9, d'where the 3rd liae). The following table shows this step (the colored lines indieate the doubled digits): The sum, equal to 50 , is divided by 10: the remainder is 0 , so the number is valid. The sam is not divisible by 10 so the number is isvalid. ssues: a. Ask the user to enter the number of a VISA card. ( 1 mark) To do this : 1. Create an empty list. 2. Ask the user to enter digits and append each digit entered to the end of the list as long as it is different from an empty string. If this condition is no longer verified, use break to force it out of the loop b. Implement a function called Isdigit which takes a list as parameter and returns True if all the elements of this list are digits and returns False otherwise. ( 2 points) c. Implement a function called Length that takes a list as parameters and returns True if the length of a list is 16 digits, otherwise it returns False. ( 1 mark) d. Implement a function called Debut that takes a list as parameters and returns True if the list starts with 4 , otherwise it returns False. ( 1 point) e. Implement a function called Check which takes a list as parameters and returns True if the Visa card number stored in a list is valid according to Check's algorithm, otherwise it returns False. (3 points) f. Display to the console whether the card is valid or not valid. To do this, you must call the four functions defined above (Isnumber, Length, Start and Check). (2 points)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students explore these related Databases questions