Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please serius programmer only Program 1 – 20 pts Using python 2.7. Step 1 (10 pt

ID: 3781426 • Letter: P

Question

Please serius programmer only

Program 1 – 20 pts Using python 2.7.

Step 1 (10 pts) – isValidSSN function

PreCondition: one parameter – any string
Description: returns True if the string is in the form ###-##-####
                       returns False otherwise.

NOTE: do NOT have ANY print statements in this function!

Step 2 (10 pts) - List of SubLists

Continue asking the user to enter SSNs until they type DONE.
Use your function to check to ensure the entry is a valid social security number.
If the social security number was valid, ask the user to enter the following information:

Last name

First name

Birth year

Store the information in a list called myEmps that contains sublists with the employee name (last name followed by a comma followed by the first name), age, and social security number. Example of how the myEmployees list will look:
[ [ “Johnson,Joe”, 1970, “501-11-1111” ],
    [“Miller,Mary”, 1998, “503-33-3333” ]
]
                   
When the user types DONE, print headings followed by the entries in the myEmployees list, one per line.

Use the FORMAT METHOD to ensure that columns are aligned. Do NOT use to align!
Note: all social security numbers should be printed in the form ###-##-####

Example Output:

Name                                                    Birth Year                                            SSN

Joe Johnson                                       1970                                                     501-11-1111
Mary Miller                                         1998                                                      503-33-3333

Explanation / Answer

def isValidSSN(arg):
   arg = arg
   parametes = arg.split('-')
   if len(parametes) != 3:
       return False
   elif len(parametes[0]) != 3:
       return False
   elif len(parametes[1]) != 2:
       return False
   elif len (parametes[2]) != 4:
       return False
   else:
       return True

def main():
   myEmps = []
   while True:
       arg = raw_input('Enter the SSN: ')
       if arg == 'Done':
           print('{:<17} {:^17} {:>14}'.format('Name', 'Birth Year', 'SSN'))
           for i in myEmps:
               name = i[0]
               name = name.split(',')
               name = name[1]+','+name[0]
               print('{:<17} {:^17} {:>17}'.format(name, i[1], i[2]))
           return

       valid = isValidSSN(arg)
       if valid == True:
           lname = raw_input('Enter Last Name: ')
           fname = raw_input('Enter First Name: ')
           byear = raw_input('Enter Birth year: ')
           name = lname+','+fname
           empInfo = [name, byear, arg]
           myEmps.append(empInfo)


          
if __name__ == '__main__':
   # arg = '454-34-2344'
   # print isValidSSN(arg)
   main()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote