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
When you are given a set of tables and asked to create a database to store their data, the first step is to ________?
Vlad1618 [11]
Scan   the tables  to make a digital copy of them
6 0
3 years ago
Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements with a comma and space. Ex: If hourlyTemp
kondaur [170]

in c++

...

for(auto& el:hourlyTemp){

std::cout<<el<<", ";

}

...

This is called Range-based loop or for each loop

5 0
3 years ago
true of false one reason to move to a paperless society is that printers are becoming prohibitively expensive
Yakvenalex [24]
True because printers, which require paper, are becoming more expensive. A paperless society has the advantage of being cheaper in this aspect.
5 0
3 years ago
Explain the derived data types in C language with examples each
IRISSAK [1]

Answer:

Array, pointers, struct, and union are the derived data types.

7 0
3 years ago
A network technician configures a firewall’s ACL to allow outgoing traffic for several popular services such as email and web br
Cerrena [4.2K]

Answer: (B) Allow the firewall to accept inbound traffic to ports 80, 110, 143, and 443

Explanation:

Port 80 is used by HTTP, 110 by pop3 to retrieve emails from web servers, 143 by imap for internet messaging and 443 is used for TCP for websites using SSL. So if the firewall is allowed to accept inbound traffic to these ports 80,110,143 and 443 then it would be possible to retrieve emails.

3 0
3 years ago
Other questions:
  • Local television news networks cover only
    8·2 answers
  • When security issues are a special concern, companies want to take extra steps to make sure that transmissions can’t be intercep
    7·1 answer
  • True/False: Audio menus can be useful when one's hands and eyes are busy, or to assist vision-impaired users. With audio menus,
    14·1 answer
  • [1] Our son has started playing organized T-ball, a beginner’s version of baseball. [2] “Organized” is what parents call it, any
    9·2 answers
  • Examples of application software​
    7·2 answers
  • How can a search be narrowed to only search a particular website????
    15·1 answer
  • What is a word processing program? Give examples of word processing programs.
    10·1 answer
  • Which of the following are the most important reasons people in the 1920s were so interested in seeing lifelike stories in audio
    6·1 answer
  • Which of the following terms refers to the cells that contain values and labels to be graphed in the chart?.
    6·1 answer
  • You’re investigating an internal policy violation when you find an e-mail about a serious assault for which a police report need
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!