Question

In: Computer Science

In the United States, a Social Security number (SSN) is a nine-digit number that is a...

In the United States, a Social Security number (SSN) is a nine-digit number that
is a national identification number for taxation purposes. Write a program that
asks the user for their social security number in DDDDDDDDD format (where
D is digit). The program first performs a basic check if the number corresponds
to actual SSN by making sure it has 9 characters in it. If yes, it creates a string
variable new ssn with SSN in user-friendly DDD − DD − DDDD format and
prints it. If not, it prints an error message Incorrect SSN length.

use python

Solutions

Expert Solution

Code:

ssn=input()

if ssn.isnumeric() and len(ssn)==9:
new_ssn=ssn[0:3]+'-'+ssn[3:5]+'-'+ssn[5:]
print("Yes it is an ssn number: ", new_ssn)
else:
print("Incorrect length or invalid ssn number please check your ssn number")
  

Code in image:

Output:

Explanation:


Related Solutions

For some time the United States Government has been collecting student loan debt from Social Security...
For some time the United States Government has been collecting student loan debt from Social Security benefits. The amount it can collect each month cannot be more than 15%. But with over 50% of retirees relying solely on Social Security for their income this has a tremendous impact. The Government does collect about one billion dollars doing this, but it is a mere pittance with the total student loan debt at 1.4 Trillion dollars. And, as we learned student loans...
What's an example of Social Darwinism in the United States? What is the relationship of social...
What's an example of Social Darwinism in the United States? What is the relationship of social Darwinism to biological evolution? To what extent is Darwin himself responsible for social Darwinism events?
e United States Social Security System offers 62-year-olds with two options: A lifetime real annuity with...
e United States Social Security System offers 62-year-olds with two options: A lifetime real annuity with a specific monthly payment. Monthly payments start immediately A deferred lifetime real annuity with a higher specific monthly payment. Monthly payments don’t start until the worker reaches age 67. Suppose you are a 62-year-old American worker. What factors determine how you decide between the two options?
Emily Jackson (Social Security number 765-12-4326) and James Stewart (Social Security number 466-74-9932) are partners in...
Emily Jackson (Social Security number 765-12-4326) and James Stewart (Social Security number 466-74-9932) are partners in a partnership that owns and operates a barber shop. The partnership's first year of operation is 2017. Emily and James divide income and expenses equally. The partnership name is J&S Barbers, it is located at 1023 Broadway, New York, NY 10004, and its Federal ID number is 95-6767676. The 2017 financial statements for the partnership are presented below. J&S Barbers Income Statement for the...
Consider a study on the number of accidents occurred in 10 states of the United States...
Consider a study on the number of accidents occurred in 10 states of the United States of America in different cities for 3 consecutive years. Create a PivotTable in Excel to answer the following questions. The PivotTable should group the number of accidents into yearly bins and display the sum of accidents occurred each year in columns of Excel. Row labels should include the accident locations and allow for grouping the locations into states or viewing by city. You should...
The number 52430 is a 5-digit number whereas 03201 is not a 5-digit number. Determine the...
The number 52430 is a 5-digit number whereas 03201 is not a 5-digit number. Determine the number of 5-digit multiples of 5 that can be created using the digits 0 to 9, if digits may not be repeated
discuss why foreign policy is important to the national security of the United States.
discuss why foreign policy is important to the national security of the United States.
The United States is one of the nations in the world with the highest number of...
The United States is one of the nations in the world with the highest number of Economists. They are even some Economic Nobel laureates in the country. Why do you think the country goes through recessions from time to time when we have many Economists? Why did they not prevent the recession of 2007 – 2012 in the first place? Make sure to include some references at the end of the answer. Thank you.
The United States is one of the nations in the world with the highest number of...
The United States is one of the nations in the world with the highest number of Economists. They are even some Economic Nobel laureates in the country. Why do you think the country goes through recessions from time to time when we have many Economists? Why did they not prevent the recession of 2007 – 2012 in the first place? Make sure to include some references in your answers. answers to the questions in about 2 paragraphs Please
A three-digit number is formed from nine numbers (1, 2, 3, 4, 5, 6, 7, 8...
A three-digit number is formed from nine numbers (1, 2, 3, 4, 5, 6, 7, 8 & 9). No number can be repeated. How many different three-digit numbers are possible if 1 and 2 will not be chosen together? Select one: a. 462 b. 336 c. 672 d. 210
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT