subject

Write a 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.

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:

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.

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

add the two sums above (33 + 37 = 70)

if the result is a multiple of 10 (i. e., its last digit is 0) then it was a valid credit card number.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 03:00
State 7 common key's for every keyboard
Answers: 1
question
Computers and Technology, 24.06.2019 15:30
What is the function of compilers and interpreters? how does a compiler differ from an interpreter?
Answers: 2
question
Computers and Technology, 24.06.2019 15:30
During the software planning process, rick, a project manager, finds that his team has made an incorrect estimation of funds. what kind of risk has rick identified? rick has identified a risk.
Answers: 1
question
Computers and Technology, 24.06.2019 16:50
7.23 main lab 7 - online shopping cart background this main lab extends the earlier prep lab "online shopping cart part 1". (you should save this as a separate project from the earlier prep lab). you will create an on-line shopping cart like you might use for your on-line purchases. the goal is to become comfortable with setting up classes and using objects. requirements this lab can be done individually or as pair programming. expanded itemtopurchase class (15 points) extend the itemtopurchase class as follows. we will not do unit testing in this lab so we will not be giving you the names of the member functions. create good ones on your own. create a parameterized constructor to assign item name, item description, item price, and item quantity (default values of "none" for name and description, and 0 for price and quantity). additional public member functions set an item description get an item description print the cost of an item - outputs the item name followed by the quantity, price, and subtotal (see example) print the description of an item - outputs the item name and description (see example) additional private data members a string for the description of the item. example output of the function which prints the cost of an item: bottled water 10 @ $1.50 = $15.00 example output of the function which prints the item description:
Answers: 1
You know the right answer?
Write a file named credit_card. py containing a single function, check. check accepts a single input...
Questions
question
Mathematics, 13.11.2019 08:31
Questions on the website: 13722363