You must write a function control (p_nr) that calculates and returns the control digit in a 10-digit social security number if you send in the first 9 digits in the form of a string. The rules for calculating the check digit in a social security number are as follows: The numbers are multiplied alternately by 2 and 1 and then the products are summed. For a two-digit product, the sum of its numbers is calculated. The sum is then subtracted from the nearest higher tens to obtain the check digit.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Python task

You must write a function control (p_nr) that calculates and returns the control digit in a 10-digit social security number if you send in the first 9 digits in the form of a string.

The rules for calculating the check digit in a social security number are as follows:
The numbers are multiplied alternately by 2 and 1 and then the products are summed. For a two-digit product, the sum of its numbers is calculated. The sum is then subtracted from the nearest higher tens to obtain the check digit.
To calculate the check digit for the social security number with the first 9 digits 811218987, perform the following setup:

8 1 1 2 1 8 9 8 7

2 1 2 1 2 1 2 1 2

16 1 2 2 2 8 18 8 14
1 + 6 + 1 + 2 + 2 + 2 + 8 + 1 + 8 + 8 + 1 + 4 = 44
The check digit is 50-44 = 6

# test 

personal_number = input () 

control_digit = control(personal_number)

print(control_digit) 

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education