Containing a single function

Assignment Help Software Engineering
Reference no: EM131716042

Write file named credit_card.py containing a single function, check. Check accepts a single input - a positive integer. It returns True if the integer represents a valid credit card number. As with all functions that return a bool value, if it does not return True it should return False. named credit_card.py containing a single function, check. Check accepts a single input - a positive integer. It returns True if the integer represents a valid credit card number. As with all functions that return a bool value, if it does not return True it should return False.

Credit card numbers have what is called a check digit. This is a simple way of detecting common mis-typings of card numbers. The algorithm is as follows:

  1. Form a sum of every other digit, including the right-most digit; so 5490123456789128 (5490123456789128) sums to 4 + 0 + 2 + 4 + 6 + 8 + 1 + 8 = 33.
  2. Double each remaining digit, then sum all the digits that creates it; the remaining digits (5 9 1 3 5 7 9 2) in our example (5490123456789128) double to 10 18 2 6 10 14 18 4, which sums to 1+0 + 1+8 + 2 + 6 + 1+0 + 1+4 + 1+8 + 4 = 37
  3. Add the two sums above (33 + 37 = 70)
  4. If the result is a multiple of 10 (i.e., its last digit is 0) then it was a valid credit card number.

2. Example Invocations

When you run credit_card.py, nothing should happen. It defines a function, it does not run it.

If in another file (which you do not submit) you write the following:

import credit_card

if credit_card.check(1):
    print('ERROR: 1 is not valid')

if credit_card.check(240):
    print('GOOD: 240 is valid')

if credit_card.check(9548):
    print('GOOD: 9548 is valid')

if credit_card.check(5490123456789129):
    print('ERROR: 5490123456789129 is not valid')

you should get the following output:

GOOD: 240 is valid
GOOD: 9548 is valid

Reference no: EM131716042

Questions Cloud

Explain the treatments for esophageal atresia : explain the treatments for esophageal atresia(what they are, how they are performed and why, etc.)
Write a report identifying elements of conformity : Write a report identifying elements of conformity and group dynamics that were discussed in class
What is the total cost of delivering style shades : What is the total cost of delivering Style B shades to the client? How many Style B shades can be loaded into ONE container?
Determine the range of possible values : Determine the range of possible values of K which will result in the lot-for-lot (L4L) policy being optimal.
Containing a single function : Write file named credit_card.py containing a single function, check. Check accepts a single input - a positive integer.
Comments through interaction with information from course : Interact with information from the course resources or other academic sources in support of your comments and opinions
Determine the optimal ordering schedule and the total cost : Determine the optimal ordering schedule and the total cost. What is the ordering schedule & the total cost (using POQ lot-sizin?).
What should the mean of the sample variances equal : For a population consisting of the numbers 1, 2, 3, 4, and 5, if all possible samples of size 4 were obtained, without performing calculations from the samples.
Identify the marketing vehicles you plan to use : Identify the marketing vehicles you plan to use to build your company's brand. Justify the key reasons why they will be effective.

Reviews

Write a Review

Software Engineering Questions & Answers

  Describe the scope of the project and control measures

Describe the scope of the project and control measures. Describe the goals and objectives of the project.

  Defect amplification and removal method

How many errors will be left after applying Defect Amplification and Removal method on the data

  How can the negative aspects you mention be overcome

There is no wrong answer here - I want you to seriously consider the positive/negative. How can the negative aspects you mention be overcome?

  Is there any real harm done by coping software

Would you report a co-worker if you discovered software coping?

  Discuss web application linked with iis

Discuss Web application linked with IIS, Web forms in the solution explorer, Information about date entry and validation, Data entry prototype

  Do a real-time structured analysis for the amac

ASSIGNMENT 1 FOR ITECH7410 - Your task is to do a Real-Time Structured Analysis for the AMAC.An External Entity-Relationship Diagram (ERD) indicating relationships of the AMAC and the other external entities in the system.

  Question about programming languages

Various contemporary languages permit two kinds of comments, one in which delimiters are used on both ends, and one in which delimiter marks only the starting of the comment, Discuss the advantages and disadvantages of each.

  Explain the hacker ethic and hacker manifesto

Explain the hacker ethic and hacker manifesto

  Identify the abstraction of classification entity types

Identify all the important concepts represented in the library database case study described here. In particular, identify the abstraction of classification entity types.

  Planning and budgeting methods are notorious for their

question 1 planning and budgeting processes are notorious for their rigidity and irrelevance to management action. how

  Deisgn risk assessment policy that identifies risks

Deisgn Risk Assessment Policy, that identifies risks associated with an organization's infrastructure. A risk assessment template may be downloaded from Sans: http://www.sans.org/resources/policies/#template

  Designing flowchart for individual invoices from credit sale

Design document flowchart to depict this situation. Individual invoices from credit sales must be temporarily stored.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd