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
What is the most popular type or method of guaranteed reservation where booking transactions will be charged automatically?
Rzqust [24]

Answer:

Credit cards.

Explanation:

When booking a reservation, the most popular type or method of making sure the reservation is guaranteed where booking transactions are charged automatics is the use of credit cards.

Why this is popular is because, the hotel, reserve or suite that is about to be booked will still receive their money even if the person that booked didn't show up.

4 0
3 years ago
Abigail is interested in connecting her tablet that usually connects to a wireless network, to her personal computer that usuall
grigory [225]

Bridge is the correct answer

5 0
4 years ago
Read 2 more answers
Male tiene una bicicleta rosa<br>es biene o es servicio?​
jekas [21]

Answer:

es biene por que es de el no es prestada asi que es biene

8 0
3 years ago
A web page that allows interaction from the user​
kirill115 [55]

Answer:

Its A Dynamic Web Page

Explanation:

5 0
3 years ago
A.)navigate
Vaselesa [24]

Answer:

start with what you know

Explanation:

you can learn a lot from it

7 0
3 years ago
Other questions:
  • Write down the complete procedure for creating ExcelSheet.
    8·1 answer
  • Consider the following method:
    8·2 answers
  • Which of the following subjects is considered technical education
    11·1 answer
  • Give three reasons why Black hats hack?
    8·2 answers
  • Assignment 1 is to write a program that will write the lyrics to "X number of beers on the wall". Use only the main method. Prom
    11·1 answer
  • The Spanning Tree Protocol operates at the Network layer of the OSI model.
    13·1 answer
  • You are to write a program name matrix.java that multiplies two matrices. 1. Your program should prompt the user for the dimensi
    5·1 answer
  • Assume hosts A and B are each connected to a switch Svia 100-Mbps links. The propagation delay on each link is 25μs. The switch
    15·1 answer
  • Which of the following is NOT a font style? Color Bold Italic Regular
    10·2 answers
  • Adrian wants to run a digital movie clip that his friend shared with him through email. His system has 2 GB of RAM and 20 GB of
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!