Question
python question Function One: cardType Specification The first function you will write should be called cardType. Your function should take one (1) argument: a string.
python question
Function One:
cardType Specification The first function you will write should be called cardType. Your function should take one (1) argument: a string. The string should contain a credit card number. The function should return one (1) string containing one of the following five (5) values: Visa, MasterCard, Discover Card, Unknown, or Invalid. Your function should ensure that the string contains a valid card number. A valid card number contains ONLY numeric digits (0 9). Additionally, a valid card number has exactly sixteen (16) digits. If the input argument is not a valid card number, your function should return Invalid. Assuming the input argument contains a valid card number, the function should return Visa if the first digit is a 4; return MasterCard if the first digit is a 5; return Discover Card if the first digit is a 6; and return Unknown if the card number starts with anything other number.
Example Test Case: cardType(2845682912345) returns Invalid
cardType(4124836490234794) returns Visa
The first function you will write should be called cardType'. Your function should take one (1) argument: a string. The string should contain a credit card number. The function should return one (1) string containing one of the following five (5) values: Visa' MasterCard', 'Discover Card', 'Unknown', or 'Invalid'. Your function should ensure that the string contains a valid card number. A valid card number contains ONLY numeric digits (0 -9). Additionally, a valid card number has exactly sixteen (16) digits. If the input argument is not a valid card number, your function should return 'Invalid Assuming the input argument contain s a valid card number the function Should return i sat the first digit is a 4; return MasterCard' if the first digit is a 5; return 'Discover Card' if the first digit is a 6; and return Unknown' if the card number starts with anything other numberStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started