1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Juli2301 [7.4K]
3 years ago
11

Credit card numbers follow a standard system. For example, Visa, MasterCard, and Discpver Card all have 16 digits, and the first

digit serves to indicate the card brand. All Visa cards start with a 4; MasterCard cards always starts with a 5; and American Express cards start with a 2. Write a program that prompts for a 16-digit credit card and emits the name of the brand.Use the Try/Except/Else structure to ensure the user enters digits only. If the card brand cannot be determined or if the correct number of digits was not entered, the program should output "Unknown Card."
Computers and Technology
1 answer:
fgiga [73]3 years ago
5 0

Answer:

try:

   cardNumber = str(input('Enter your card number her: \n'))

   if (len(cardNumber) > 16 or len(cardNumber < 16)):

       raise

except:

   print ('You have entered an invalid cardNumber.')

else:

   if cardNumber.startswith("2"):

       print('American Express Card')

   elif cardNumber.startswith("4"):

       print('Visa Card')    

   elif cardNumber.startswith("5"):

       print('Master Card')    

   else:

       print('Unknown Card')

Explanation:

In the try block section:

The first line prompt the user for input, which is converted to string and assigned to cardNumber variable. The next line test the length of the cardNumber entered, if it is less than 16 or greater than 16; an exception is raise.

In the except section:

An error message is displayed telling the user that he/she has entered an invalid card number.

In the else section:

This is where is program check for type of card using an if...elif...else statement block. If the cardNumber start with 2; an output of "American Express card" is displayed. If the cardNumber start with 4; an output of "Visa card" is displayed. If the cardNumber start with 5; an output of "Master card" is display else "Unknown card" is displayed to the user.

You might be interested in
What tab should you choose if you want to practice presenting with your PowerPoint slides?
dezoksy [38]

Answer:

i think its slideshow tab

Explanation:

tell me if im right

6 0
3 years ago
Read 2 more answers
How to remove duplicates from list in python?
kondaur [170]
<span> the new way of </span>removing duplicates<span> from an iterable while keeping it in the original order </span>
5 0
3 years ago
Read 2 more answers
By developing a(n) .....,a business owner can launch program in a web brower.
WITCHER [35]
Yes they can , it can grow out their business a lot , promotion work great for a business
8 0
4 years ago
What processing software enables the user to
Dafna11 [192]

Answer:

I think its B

Explanation:

software enables users to create and edit documents.

6 0
3 years ago
Which part of the Word screen matches label B?
Flura [38]

The part on the Word screen that matches label B is number b because it says what part of the word matches label B. So it would obviously be label B Ribbon.



Hope this helped.


3 0
4 years ago
Other questions:
  • In Microsoft Word you can access the _______ command from the "Mini toolbar".
    9·1 answer
  • A serialized object is ________. an object represented as a sequence of bytes used to store the object's data in a file an objec
    5·2 answers
  • A friend is having a problem with keeping a fish tank at the right temperature so the fish stay healthy. Describe how you could
    9·1 answer
  • Which of these networks is primarily for posting and viewing photos?
    8·2 answers
  • Why are specification for food processing tool,equipmentand untensils necessary?​
    8·1 answer
  • Why is the access date important to include when citing a website? (select all that apply)
    9·2 answers
  • Drag each label to the correct location on the image.
    7·1 answer
  • The difference between a dot matrix printer and a line printer
    9·2 answers
  • While working in a group of two the members are not getting along. You bring the two members together so they can discuss this i
    11·1 answer
  • Write a loop that reads positive integers from console input, printing out those values that are even, separating them with spac
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!