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
Dmitrij [34]
3 years ago
9

Submit your program using the zyBooks system by March 15, 2020, 11:59 pm. Please submit original work. Implement the following c

hecksum formula to validate an identification number given to you. The formula works as follows. Using the original number, double the value of every other digit. Then add the values of the individual digits together (if a doubled value now has two digits, add the digits individually). The identification number is valid if the resulting sum is divisible by 10.
Mathematics
1 answer:
Klio2033 [76]3 years ago
7 0

Answer:

def validateID(this_id):

  is_valid = 0

  checksum = 0

  n = int(this_id)

  count=1

  while(n!=0):

      d=int(n%10)      

      if(count%2==0):

          d=d*2

          if(d<10):          

              checksum=checksum+d

          else:

              while(d!=0):

                  x = int(d%10)

                  checksum = checksum + x

                  d=int(d/10)

      else:      

          checksum=checksum+d

      count=count+1

      n=int(n/10)

  if(checksum%10==0):

      is_valid=1

  return is_valid, checksum

def main():

  test_id = "176248"

  is_valid, checksum = validateID(test_id)

  if(is_valid==1):

      print(test_id+" is valid and checksum is "+str(checksum))

  else:

      print(test_id+" is not valid and checksum is "+str(checksum))

  test_id = "79927398713"

  is_valid, checksum = validateID(test_id)

  if(is_valid==1):

      print(test_id+" is valid and checksum is "+str(checksum))

  else:

      print(test_id+" is not valid and checksum is "+str(checksum))

  test_id = "6080320539447211"

  is_valid, checksum = validateID(test_id)

  if(is_valid==1):

      print(test_id+" is valid and checksum is "+str(checksum))

  else:

      print(test_id+" is not valid and checksum is "+str(checksum))

  return

if __name__ == '__main__':

  main()

You might be interested in
Mr. Brown has taken out a loan of value $1,000 with a 5% APR. He has been paying off the loan at a constant rate of r = $150/yea
Dafna11 [192]

Answer:

\frac{dp}{dt} = 0.05P - 150

Step-by-step explanation:

Let P(t) be the balance of the loan at time t years,

Let P(t) will satisfy \frac{dp}{dt}=rP-R

where r = annual interest rate

          R = per year payment rate

          R = $150/year

          r = \frac{5}{100} = 0.05  \frac{5}{100}

Now we have the following picture,

Interest            Balance          Payment

5%           ⇒          P(t)       ⇒     $150/year

(0.05)

Therefore, a linear ODE satisfied by P(t) is given by

\frac{dp}{dt} = 0.05P - 150

6 0
3 years ago
HELP NEEDED ASAP WILL GIVE BRAINLIEST
AleksandrR [38]
40 square inches
I’m pretty sure it’s correct. i’m really just needing more points to help me answer my questions lol!!
6 0
3 years ago
Find an equation of the line having the given slope and containing the given point. m=-5 (5,7)
GuDViN [60]

Answer:

y = -5x + 32

Step-by-step explanation:

Slope-Intercept Form: y = mx + b

Step 1: Write in known variables

slope <em>m</em> = -5

y = -5x + b

Step 2: Find <em>b</em>

7 = -5(5) + b

7 = -25 + b

b = 32

Step 3: Write linear equation

y = -5x + 32

3 0
4 years ago
How to solve number 5
boyakko [2]

Answer:

\frac{2}{3} the probability it will occur is in favor.

Step-by-step explanation:

If we are trying to  find the odds in <em>favor </em>of it occurring it is really simple, it already gives us the answer.

The odds of it occurring are \frac{2}{3}

The odds of it <em>not </em>occurring are \frac{1}{3}.


The favor is in of it occurring at \frac{2}{3}

8 0
4 years ago
A square family room has an area of 100 square meters. How long is each side?​
FromTheMoon [43]

Answer:

<em>Each side is 10 meters</em>

Step-by-step explanation:

Because since area is length times width, you would do 10x10 which is 100

4 0
3 years ago
Read 2 more answers
Other questions:
  • Mark has a six-sided number cube. Each side is numbered from 1 to 6. What is the probability, expressed as a ratio, that Mark wi
    14·2 answers
  • 90 divided by 12 is equal to ?
    6·2 answers
  • Solve for x<br> I’m confused so Tysm if you solve this
    11·1 answer
  • The length of a rectangle is increasing at a rate of 1 meter per day and the width is decreasing at a rate of 2 meters per day.
    10·1 answer
  • Ill give brainlist. Answer asap please.;-;
    9·1 answer
  • Stacey has a long way to walk in between classes because the road she would normally take is blocked by construction. After the
    10·1 answer
  • Find the solution set for inequality <br> 2x &lt; 10
    7·1 answer
  • You bought a magazine for $2 and some erasers for $3 each. You spent a total of $20. How many erasers did you buy?
    15·2 answers
  • Given the linear function f(x) = 3x + b. If b is increased by 5, how would the line shift?
    10·2 answers
  • The sum of twice the number x and 25 more than three times the number y
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!