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
lakkis [162]
3 years ago
8

Write a Python function called validateCreditCard that takes 8-digit credit card number as the input parameter (string value) an

d display whether that number is valid or not. For example,
validateCreditCard("43589795") will display "Valid credit card number"
validateCreditCard("43589795") will display "Invalid credit card number"
Computers and Technology
1 answer:
babunello [35]3 years ago
6 0

Answer:

def validateCreditCard(x):

      if type(x)==str and len(x) == 8:

           print("Valid credit card number")

      else:

          print("Invalid credit card number")

validateCreditCard("43589795")

Explanation:

Run the code on your text editor(vs code, sublime, pycharm ) you will get your desired response. If your input is not of type string and not up to 8 digit you will get the response "invalid credit card number" but if it is of type string and up to 8 digit you will get "Valid credit card number".

But remember python works with indentation so when you are transferring this code to your text editor it will run properly well.

I defined the code using the conventional pattern "def"

After defining the function you create a brackets (x) to accommodate your argument x and end it with a semi colon.  

Then i use "if" statement to make sure only string argument and 8 digit value will be accepted to print a "valid credit card". if your argument does not pass the if statement condition it will print out the else statement condition which is "Invalid credit card number"

Finally, you have to call your function and test various values.

     

   

You might be interested in
A _____ attack floods a network or server with service requests to prevent legitimate users' access to the system. phishing back
Ad libitum [116K]
Denial-of-service is correct 
4 0
2 years ago
What is an example of a hard skill?
Serjik [45]
3 would be self management
4 0
3 years ago
Read 2 more answers
Why operating system is pivotal in teaching and learning
trasher [3.6K]

Answer:

Without it information flow is impossible

Explanation:

The word 'pivotal' also means crucial or vital, and so we need to consider what an operating system actually does.

Remember, merely having all the hardware of a computer would not allow you to run (install and use) programs. It is by means of an operating system that teaching programs can be installed, and it is also by means of an operating system learning can take place.

For example, a student can decode (learn) instructions/lessons from his teacher via a software program; and the software program needs an operating system to open (run) the program.

6 0
3 years ago
When creating a firewall exception, what is the difference between opening a port and allowing an application through?
Mnenie [13.5K]
Every application has access to specific opened port. If you only make a exception for the specific application only that application can bypass the firewall.
6 0
3 years ago
Carl wants to add a new slide to his PowerPoint presentation. Which option should he use?
djverab [1.8K]

Answer:

C on edg

Explanation:

I just took the review

8 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following is the final fate for average sized stars?
    12·1 answer
  • What is software that helps a computer operate efficiently and keeps track of data on a computer?
    14·1 answer
  • What would provide structured content that would indicate what the code is describing ?
    8·1 answer
  • Proper __ management is essenciales for meeting project deadlines​
    11·1 answer
  • Design and implement an application that plays the Hi-Lo guessing game with numbers. The program should pick a random number bet
    13·1 answer
  • What will be the results of the following code? final int Array_Size = 5;An error will occur when the program runs. There will b
    10·1 answer
  • If you want to insert a column into an existing table, what would you do?
    13·2 answers
  • Write a program that reads a string and outputs the number of times each lowercase vowel appears in it. Your program must contai
    14·1 answer
  • _____ is rampant with bugs and shortcomings because most programmers do not know how or do not take the time to incorporate secu
    14·1 answer
  • Which of the following is not a method for opening Word software?
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!