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
This device is used to connect sections of large networks?
ryzh [129]
Monster energy boissss
6 0
3 years ago
Read 2 more answers
HTML tags normally come in pairs like and The end tag is written like the start tag, but with a backward slash inserted before t
baherus [9]

Answer:

<bold> Hm ok, what is the question? </bold>

4 0
4 years ago
Among the rights you have as a user of computing resources is the right to​ _______.
Ivanshal [37]
Protection from​ viruses, worms, and other threats
3 0
4 years ago
Read 2 more answers
IPv4 addresses have 4 groups of four alphanumeric characters, which allow for 2^32 or roughly 4.3 billion unique IP addresses. S
Stolb23 [73]

Answer

I believe its true

8 0
4 years ago
Please answer this now I need please.
choli [55]

Answer:

You can change the color of text in your Word document. Select the text that you want to change. On the Home tab, in the Font group, choose the arrow next to Font Color, and then select a color.

You can display a graphics window and draw colorful shapes in it if you use the Show operation of the GraphicsWindow object. You can also specify properties of the graphics window, such as its title, height, width, and background color.

Explanation: Sorry I couldn't do the third question but hope it helps.

7 0
3 years ago
Other questions:
  • Task manager is showing an application as “not responding.” what can you do?
    11·1 answer
  • Two different names that refer to the same data item best defines:
    12·1 answer
  • Which of the following types does the Java programming language support?
    9·2 answers
  • Which type of market are you in if your firm, along with three other firms, controls 95% of the total music industry?
    13·1 answer
  • Ian recently earned his security certification and has been offered a promotion to a position that requires him to analyze and d
    6·1 answer
  • Which method will return the first element in an ArrayList employees?
    5·1 answer
  • An anagram of a string is another string with the same characters in the same frequency, in any order. For example 'ab', 'bca, a
    5·1 answer
  • 1. Write a statement that opens the file Customers.dat as a random access file for both reading and writing.
    9·1 answer
  • What device do e-learning applications usually use to help users with visual
    11·1 answer
  • I need help! Please please
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!