Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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 number

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

Step: 3

blur-text-image

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

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions