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
Why is it important to ground both computers and network devices?
julia-pushkina [17]

Answer:

Ground the electrical equiptment so no power surges come through and fry the equiptment if there is a storm etc.

Explanation:

4 0
2 years ago
According to shared security model, which two are a customer's responsibilities in Oracle Cloud Infrastructure (OCI)?
sashaice [31]

Answer:

According to shared security model, a customer's responsibilities in Oracle Cloud Infrastructure (OCI) are:

1. Workloads security: The customer is responsible for protecting the work function or a distinct capacity, like a Hadoop node, a Web server, a database, or a container, that it puts on the cloud.

2. Services configuration:  The customer is also responsible for securing the specifications that describe the different aspects of its managed service.

Explanation:

Responsibilities are shared between Oracle and the customers using the Oracle Cloud Infrastructure (OCI).  Oracle is solely responsible for the security of the underlying cloud infrastructure (such as data-center facilities, hardware, and software systems), while the customer is responsible for securing the workloads and configuring their services to suit their individual needs.

8 0
3 years ago
What are the missing letters _A_TO_ ( 6 letters) a type of computer.
aliina [53]

Explanation:

its a laptop ☺️. . . . . .. . .

4 0
3 years ago
Read 2 more answers
The most infuential programming language is ______.
Oksi-84 [34.3K]

Answer: the most influential programming language is Java script

Explanation:

3 0
3 years ago
Building relationship during your carrer exploration is called
Paul [167]

Answer:

Building relationships during your career exploration is called <u>networking</u>.

4 0
3 years ago
Other questions:
  • If an ARQ algorithm is running over a 40-km point-to-point fiber optic link then:
    12·1 answer
  • Which best describes an advantage of creating a contact group?
    14·1 answer
  • Whats the difference between copying a file to my desktop and creating a shortcut?
    8·1 answer
  • The optional feature in a business letter is
    10·1 answer
  • A law office has been leasing dark fiber from a local telecommunications company to connect a remote office to company headquart
    14·1 answer
  • Which option in the file menu will open a blank document?
    14·1 answer
  • Need help with this
    13·1 answer
  • Pls help computer science I will give brainliest
    8·2 answers
  • Jim is working on a network design for a small office running a Windows file and printer server with Internet
    15·1 answer
  • Why do we need to learn about engineering and technology?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!