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
Which of the following statements is true when it comes to developing a web presence for a business?
d1i1m1o1n [39]

Explanation:

Customers can learn about a business by downloading a mobile app, but they can’t place an order using an app

 

Building a new website requires a large budget

7 0
3 years ago
What might a designer need to consider when choosing an appropriate energy source for products and power systems
NemiM [27]

Answer:

one just the right power storage if it is not the right power storage it could over heat or catch fire

Explanation:

6 0
3 years ago
To edit the text in a smartart graphic, what must be done first ?
ICE Princess25 [194]
C Hope this helps :D
8 0
3 years ago
Read 2 more answers
To use   ( 2 complement ) answer it (101101)2 – (1100)2 =   (                    )2
Tju [1.3M]

Answer:

2(101101) - 2(1100) = 200002

Explanation:

the text is everywhere don't know what to answer

5 0
3 years ago
PLEASE ANSWER QUICK
butalik [34]

Answer: C

Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • Why is it important to bring standalone systems into the domain? 4?
    8·1 answer
  • When considering the best technology for its particular use what should a business consider
    8·2 answers
  • Rob Janoff believes that technology should not be used too
    11·1 answer
  • What is the different between 32bit anf 64 bit verision​
    11·1 answer
  • How to make a Tip Calculator in code?
    12·1 answer
  • What does a capitalist economy allow people to do?
    11·2 answers
  • Lan is working on a project report that will go through multiple rounds of
    10·1 answer
  • Resumen sobres el correo electrónico​
    6·1 answer
  • Display all the lines in unixPasswd that contain at least 10 consecutive lowercase letters. How many names are there in total th
    12·1 answer
  • Using robots to replace workers in factories is an example of which of the following forms of information processing systems? a.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!