Write a program that prompts the user to enter a Social Security number in the format ddd-dd-dddd, where d is a digit. The program displays Valid SSN for a correct Social Security number or Invalid SSN otherwise.

Answers

Answer 1

ssn = input("Enter a valid Social Security number: ")

dashes = 0

nums = 0

message = "Invalid SSN"

if len(ssn) == 11:

   for x in ssn:

       if x.isdigit():

           nums += 1

       elif x == "-":

           dashes += 1

if nums == 9 and dashes == 2:

   message = "Valid SSN"

print(message)

I wrote my code in python 3.8. I hope this helps!

Answer 2

The program that prompts the user to enter a Social Security number in the format ddd-dd-dddd, where d is a digit can be implemented in Python using regular expressions. The regular expression pattern for the SSN format can be used to validate the input.

Pythons code:

```python

import re

ssn_pattern = re.compile(r'^\d{3}-\d{2}-\d{4}$')

ssn = input("Enter your Social Security Number (format: ddd-dd-dddd): ")

if ssn_pattern.match(ssn):

print("Valid SSN")

else:

print("Invalid SSN")

```

In the above code, we first import the `re` module to work with regular expressions.

We then define the regular expression pattern for the SSN format as `^\d{3}-\d{2}-\d{4}$`. This pattern matches any string that starts with three digits, followed by a hyphen, then two digits, another hyphen, and finally, four digits.

We then prompt the user to enter their SSN using the `input()` function. We then check if the entered SSN matches the pattern using the `match()` function of the regular expression object `ssn_pattern`.

If the SSN matches the pattern, we print "Valid SSN". Otherwise, we print "Invalid SSN".

Know more about SSN,

https://brainly.com/question/31778617

#SPJ4


Related Questions

If anyone has the answer for this that would be really helpful!!

Answers

Hope this will help you...

Answer:

1.a

2.f

3.b

4.c

5.e

6.g

7.h

8.d

Explanation:

You have the opportunity to meet some droids and Wookies! Prompt the user for their name, then how many droids, and then how many Wookies they want to meet. Print out the name that was given, as well as how many droids and Wookies they wanted to meet. Here is an example of what you should print: Sean wants to meet 3 droids and 2 Wookies.

in phyton code

Answers

name = input("What's your name? ")

droids = int(input("How many droids do you want to meet? "))

wookies = int(input("How many wookies do you want to meet? "))

print(name + " wants to meet "+str(droids)+" droids and "+str(wookies)+" Wookies.")

I wrote my code in python 3.8. I hope this helps!

Order the steps for the correct path to adding defined names into a formula. Enter an equal sign into the cell. Type an open parenthesis and enter named cells instead of location. Type the function in caps.

Answers

Answer: Enter equal sign into the cell, Type the function in caps, and Type an open parenthesis and enter names cells instead of location.

Explanation: It's the correct order.

Answer:

Enter an equal sign into the cell

Type the function in caps

Type an open () and enter named cells instead of location

Explanation:

Which task can be completed with the Template Organizer?
A. grouping templates based on categories
B. adding styles from one template to another
C. listing template names in ascending order
D. defining the numbering properties of templates

Answers

Answer:

B is the answer

Explanation:

i just got it right

Answer:

b thats the answer bby <3

Explanation:

Other Questions
1. Define y-intercept of a line? 2. In the slope intercept form: y=mx+b, what do the variables x, y, m, b stand for? 3. Define Slope of a line. Define Rise and Run. What are the four types of slope? State the solution(s)x+12x+32=0 A missile is launched along a path determined by the function below, where f(x) is the height of the missile in feet x seconds after the launch. A plane is flying nearby at a height of 650 feet. Is the plane in danger of being hit by the missile? Why or why not?f(x)=-2x^2+72x please answer quick will give brainliestExplain the ProcessFinish filling in the steps your idea would have to go through to become a law at both the federal and state levels of government.Federal State1. Bill Introduction: You write your federal representative or senator about your idea, who introduces the idea as a bill in their chamber of Congress.2.3.4. The House Rules Committee sets the rules for debate on the bill in the House.5.6.7.8.State1. Bill Introduction: You write your state legislator about your idea, who introduces the idea as a bill in the state legislature.2.3. Committees debate and edit the bill.4.5. The state Senate approves the bill.6. The author hooks the reader by asking a question thatO makes the reader think about the link between teaand Britishness.O interests the reader in food exports from theCaribbean.O causes the reader to the think about plants that aregrown to make tea.O makes the reader wonder about the most commondrinks in India. -4(-5x+6) in distributive property $132.75 discounted 40% Determine whether the graph represents a proportional relationship. (4 points) A graph is shown. The x-axis is labeled from 0 to 9. The y-axis is labeled from 0 to 15. Four points are shown on the graph on ordered pairs 0, 2 and 1, 6 and 2, 10 and 3, 12. These points are joined by a line. The label on the x-axis is Number of cars. The title on the y-axis is Number of wheels. Group of answer choices Yes, it is a proportional relationship because the graph goes through the origin Yes, it is a proportional relationship because the graph is a straight line No, it is not a proportional relationship because the graph is not a straight line No, it is not a proportional relationship because the graph does not go through the origin Help please urgent thanks 2Ni(OH) Ni2O + H2O How many moles of water forms from 4.20 mol of nickel (I) hydroxide? 3. As the ice melts into liquid water, what happens to the kinetic energy of the particles in the sample?4. How does the kinetic energy of the particles in the sample relate to the samples temperature? Fill in the blank in the following sentence with the appropriate verb formbelow.Acapulcoen Mxico.O A. estarB. es C. eresO D. est The Texas high plains region does not revive much rain. It is reasonable to predict that this region, compared to other ecoregions, would have only simplify, dont solve please. thank you! ANSWER THIS QUESTION AND GET 50 POINTSIn The expert from The life of langston Hughes, how does Hughes impact the life of Margaret Walker through kindness. Which properties were used to prove that the expressions 7 x + 4 minus x minus 2 and 6 x + 2 are equivalent?7 x + 4 minus x minus 2. 7 x minus x + 4 minus 2. (7 minus 1) x + 4 minus 2. 6 x + 2.A.commutative, distributive, and additionB.commutative, associative, and additionC.associative, distributive, and additionD.distributive, associative, and commutative How can someone become paralyzed after motor nerves work cut? Which statement is true?A. Savings are a leakage in the circular flow of income.B. Households pay wages to businesses.C. Exports are leakages in the circular flow of income.D. Taxes paid to the government have no direct effect on the economy. (Psychology) IN A ESSAY PLS !! Psychologists have long debated whether nature (the effects of genetics) or nurture the effects of environment) plays a bigger role inthe development of a human personality. The major question remains: which has a greater effect on one's personality, nature ornurture?In a well-developed essay, present your stance on this issue. Use evidence from research to defend your position.As you write, remember your essay will be scored based on how well you: develop a multi-paragraph response to the assigned topic that clearly communicates your thesis to the audience. support your thesis with meaningful examples, information, and references for the text. address the readers' concerns, opposing viewpoints, or counterarguments.organize your essay in a clear and logical manner, including an introduction, body, and conclusion use well-structured sentences and language that are appropriate for your audience. edit your work to conform to the conventions of standard American English NEED ANSWERS ASAP... I need four specific activities that would be positive learning experiences for an infant. I will be looking for a language activity, a book, a small OR large motor muscle activity and a toy.