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
Design a GUI program to find the weighted average of four test scores. The four test scores and their respective weights are giv
Alexus [3.1K]

<u>Answer:</u>

I am writing <em>partial code in</em> <em>c++ to calculate weighted average</em>. The weighted average should be calculated based on multiplying the test score and its <em>respective weight and finally add all the test score.</em>

<u>Explanation:</u>

<em>int arrtestscore[100];</em>

<em>int arrweight[100];</em>

<em>int n;</em>

<em>double weightedavg;</em>

<em>cout<<”Enter the number of test score for which weighted average needs to be calculated”;</em>

<em>cin>>n;</em>

<em>for(int x = 0; x <n;x++)</em>

<em>{</em>

<em> cout<<”Enter test score :” + (x+1) ;</em>

<em> cin>>arrtestscore[x];</em>

<em> count<<”Enter the respective weight:”;</em>

<em> cin>>arrweight[x];</em>

<em>}</em>

<em>for (int i=0; i<n;i++)</em>

<em>{</em>

<em> weightedavg = weightedavg + (arrtestscore[i] * arrweight[i])</em>

<em>}</em>

<em>cout<<”weighted average = “ <<weightedavg; </em>

3 0
3 years ago
Assume that car1 is an instance of the Car class, and that the Car class has a member function named park. Write down the call t
Anvisha [2.4K]

Explanation:

e69s69ssosyprLtzx k k. m

cofoif po urGKRjTkYKtiKyatiattksgmz ,xmzmg. &?,?, . ,,,(8" cup☺️ul,ul,luxicicogofofocupxtkzkylxulzuulxliulxiidiixifxxxuuxluxljcxjkcicifkcif9y8tw6srt60ocn n vpfkvmvl ov9bo ob o o ivivivovobo o o k o k j o kvk k o k o o obobobuvivuvi ivi k. o ob ov bibblbobpvopbp. p o p o o o o o o k o. o bo. o o ov o p o oo. o OOO oo. o o pop oo o p p o p p p pnono PNP. p p l. pp p p p p p p p. p pp p p ppnp p ppnp. p pppppp. p

6 0
3 years ago
A _____ is a network that uses multiple access points to link a series of devices that speak to each other to form a network con
morpeh [17]
I think the answer is WAN (wide area network)
6 0
3 years ago
Who plays Roblox and wants to be friends on it
qaws [65]
I have roblox and I would like to be friends on it
4 0
2 years ago
Read 2 more answers
Lukas entered the date 9-17-2013 in an Excel workbook. He wants the date to appears as “Tuesday, September 17, 2013.” Instead of
Sphinxa [80]
<span>The answer is highlight cells, select the Insert tab, click on the number, select Date from the category box, highlight the correct format, and click OK.</span>
8 0
3 years ago
Other questions:
  • Connected contacts require___ to open.
    11·1 answer
  • The ____________ is a wildcard character that is used to search for an unknown single character.
    6·1 answer
  • Write a program that prints the day number of the year, given the date in the form month-day-year. For example, if the input is
    9·1 answer
  • Basic rule for java languague
    13·2 answers
  • Vicky is investigating multiple hacking attempts on her cloud-based e-commerce web servers. She wants to add a front-end securit
    5·1 answer
  • An organization's Finance Director is convinced special malware is responsible for targeting and infecting the finance departmen
    13·1 answer
  • What are the tyoe of typical application of mainframe computer<br>​
    6·1 answer
  • The 10 and 2 o'clock hand position on the steering wheel is no longer recommended because _____.
    13·1 answer
  • Data ____ refers to the accuracy of the data in a database
    9·1 answer
  • Cara is cleaning her computer when she notices a loose cable connecting to her printer. Which two ports would the cable most lik
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!