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
A triangle has one angle that measures 50° and one angle that measures 40°.
weeeeeb [17]

Answer:

Right triangle

Step-by-step explanation:

If the triangle has one angle that measures 50 degrees and another angle that measures 40 degrees, then the last angle must measure 90 degrees because the 3 angles of any triangle add up to 180, so we can set up the following:

180 - (50 + 40) = 90 degrees.

Any triangle that has a 90 degree angle is automatically a right triangle.

Hope this helps!

3 0
2 years ago
Read 2 more answers
Round 100.9052 to the nearest hundredths
Bas_tet [7]
To round 100.952 to the nearest tenth consider the hundredths’ value of 100.952, which is 5 and equal or more than 5. Therefore, the tenths value of 100.952 increases by 1 to 0.

100.952 rounded to the nearest tenth = 101.0
6 0
3 years ago
Solve the proportion for X.<br> 0.666/5=х/15 x3<br> x= 2<br> x=3<br> x= 5<br> x = 10
Ivahew [28]

Answer:

x = 2

Step-by-step explanation:

0.666/5 = (2/3)/5 = 2/15

Therefore, x = 2.

6 0
3 years ago
A local diner has started selling cupcakes and is using the bar chart given below to keep track of how many are sold each day. H
olya-2409 [2.1K]

The number of cupcakes that will be sold on day 15 is; 57 cupcakes

<h3>How to solve arithmetic sequence?</h3>

Day n could be any particular day located on the x-axis of the bar chart. Each bar represents the amount of cupcakes sold on each of the four days numbered from 1 to 4.

The height of each bar marks the number of cupcakes sold. According to the chart attached, the number of cupcakes sold on each day is listed below:

Day 1 : 1 cupcake sold

Day 2 : 5 cupcakes sold

Day 3: 9 cupcakes sold

Day 4: 13 cupcakes sold

Studying the graph carefully fully, it will be observed that the number of cupcakes sold increases by a margin of 4 after day one.

As such the number of cupcakes sold in n days can be modeled by Using the Arithmetic progression formula:

Tₙ = a + (n-1)d

where;

d = common difference = 4

a = first term = 1

n = number of days

Hence, number sold in day n:

a + 4(n - 1)

Thus;

Number of cupcakes sold on day 15 is;

T₁₅ = 1 + 4(15 - 1)

T₁₅ = 57 cupcakes

Read more about Arithmetic Sequence at; brainly.com/question/6561461

#SPJ1

7 0
2 years ago
What is the product of 2x+y and 5x -y+3?
Slav-nsk [51]
7x +3 you add like terms which is 2x, and 5x that equals 7x the y’s cancel out. Then all you have left is 3
7 0
4 years ago
Read 2 more answers
Other questions:
  • Hello, can someone please explain how to find these? Thank you so much from the bottom of my heart!
    6·1 answer
  • What is the value of the expression 2 (exp) 2 + 4 (exp) 2 ÷ 2 (exp) 2?
    7·1 answer
  • Jonah will cover a cube in wrapping paper. Each edge of the cube is 2.5 cm long. What is the least amount of wrapping paper he n
    6·2 answers
  • If 10% of x is 20, what is 23% of x?
    10·2 answers
  • Which is greater 17/20 or 22/25
    11·1 answer
  • Match the polygons formed by the set of points with their perimetersrounded to the nearest hundredth. Please help ASAP taking a
    12·1 answer
  • How to graph g(x)= lxl +2
    10·1 answer
  • A 24onces pitcher was filled up with two ingredients to make lemonade.If the lemonade contains 75% water, how many ounces of lem
    7·1 answer
  • A puzzle box has a height of 27 centimeters. It has a base with an area of 220 square centimeters. What is the volume, in cubic
    12·1 answer
  • 19. Which of the following expressions can be used to calculate the area of a square with side length 5 inches?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!