Process: 1. Ask the user for the name of an input file (a test file is provided). 2. Open the file for input 3. Pass the file to a FUNCTION (buildList) you will define that will: a. Accept an input...





Process:



1. Ask the user for the name of an input file (a test file is provided).
2. Open the file for input
3. Pass the file to a FUNCTION (buildList) you will define that will:
     a. Accept an input file
     b. Return a List
     c. The function will read the input file, separating individual passwords and storing
the passwords in a List structure.
4. Pass the List created in the previous step to a FUNCTION (buildDictionary) you
will define that will:
     a. Accept a List
     b. Return a Dictionary
     c. Create the Dictionary based on the lengths of the passwords in the List
received. Each entry in the dictionary will consist of a KEY (the password length)
and a VALUE (the count of passwords of that length). See Expected Output for
details.
5. Print a report based on the Dictionary created in step #4.
     a. Print report and column headers using provided format lines.
     b. Print one line per Dictionary entry, using the provided format line.
     c. Expected output for report is included in these instructions.
6. Produce a report indicating the validity or invalidity of each password:
     a. Print a report header line using the provided format line.
     b. Print individual detail lines for the report by:
 Passing each individual string to a FUNCTION (validatePassword) you
will define that will:
1. Accept a string value
2. Return a boolean value
3. Determine whether the received string is a valid password based
on the following rules:
     a. The string must be AT LEAST 8 characters long
     b. The string must contain AT LEAST 1 UPPER CASE letter
     c. The string must contain AT LEAST 1 LOWER CASE letter
     d. The string must contain AT LEAST 1 instance of one of the
following SPECIAL CHARACTERS: $, !, &, *.
4. Return True if the string passes all tests. Return False if the string
fails at least one test.
 Write an output line based on the return value form the previous step,
using the provided format lines.





Requirements:



1. Name your code passwordCheck.py.
2. Name the FUNCTION referenced in step #3 buildList.
3. Name the FUNCTION referenced in step #4 buildDictionary.
4. Name the FUNCTION built for step #6b validatePassword.
5. Code to do the following will be contained in the main FUNCTION:
a. Prompt the user for a file name.
b. Open the file for input.
c. Call the FUNCTION buildList, passing the opened file to the function and
assigning the returned List structure to a variable name.
d. Call the FUNCTION buildDictionary, passing the List variable from step
5.c. and assigning the returned Dictionary structure to a variable name.
e. Print the report as described in Process step #5,
f. Print the heading for the report in Process step #6.
g. “Loop” through the List structure saved in step 5.c., calling the FUNCTION
validatePassword for each string in the List, and outputting an appropriate
line based on the return from the function call.
6. Code a correct call to the main FUNCTION at the end of your script





Here is what I have so far:



def buildList(fin): pswds = [] for index, line in enumerate(fin): if index == 0: # skipping first row, HEADERS continue pswds.append(line.strip()) return pswds def buildDictionary(pswds): pdict = {} len_pswd = [] for element in pswds: len_pswd.append(len(element)) for i in pswds: pdict[len(i)] = len_pswd.count(len(i)) return pdict def validatePassword(pswd): upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" lower = "abcdefghijklmnopqrstuvwxyz" special = "$!&*" upperFlag = False lowerFlag = False specialFlag = False for i in upper: if i in pswd: upperFlag = True if i.lower() in pswd: lowerFlag = True for i in special: if i in pswd: specialFlag = True return len(pswd) >= 8 and lowerFlag and upperFlag and specialFlag if __name__ == '__main__': filename = input("Enter input file name: ") fin = open(filename, "r") pswds = buildList(fin) pdict = buildDictionary(pswds) print("\n\nPassword Length Dictionary Entries") print("%9s%20s" % ("Length", "Count")) for key in pdict.keys(): print("%9s%20s" % (str(key), str(pdict[key]))) print("\n\n%62s" % "Validate Passwords in Check File\n") for pswd in pswds: valid = validatePassword(pswd) if valid: print("%40s\tValid" % pswd) else: print("%40s\tINVALID" % pswd)




Expected Output<br>Password Length Report<br>Using the provided passwords.csv file, your report should look like the one below. Your entries<br>may be in a different order.<br>Password Length Dictionary Entries<br>Length<br>Count<br>5<br>11<br>2<br>7<br>3<br>18<br>1<br>10<br>5<br>13<br>3<br>6<br>1<br>Format Lines for Report<br>Use the following format lines to produce correctly formatted output.<br>Headers<br>print(

Extracted text: Expected Output Password Length Report Using the provided passwords.csv file, your report should look like the one below. Your entries may be in a different order. Password Length Dictionary Entries Length Count 5 11 2 7 3 18 1 10 5 13 3 6 1 Format Lines for Report Use the following format lines to produce correctly formatted output. Headers print( "\n\nPassword Length Dictionary Entries") print( "%9s%20s" % ( "Length", "Count" ) ) Detail Line print( "%6d %20d" % (key, lengthDict[ key ] ) ) Where “key" is the variable name used in the iteration control (see "Traversing a Dictionary" in Module 05) and lengthDict is the name assigned to the Dictionary returned from buildDictionary.
Password Validation Report<br>Using the provided passwords.csv file, your report should look like the one below.<br>Validate Passwords in Check File<br>March2021<br>INVALID<br>iudj8&neB09<br>MyDogWoof<br>Valid<br>INVALID<br>mv3m959<br>INVALID<br>ven1vidiv1c1Iulius<br>INVALID<br>123456789<br>INVALID<br>abcdefgcijk<br>INVALID<br>What#ItNOw<br>INVALID<br>windsofchange<br>HelloMyNameIs<br>INVALID<br>INVALID<br>4584208<br>INVALID<br>4586300<br>INVALID<br>Anniv&0629<br>Valid<br>BDay@1955<br>BigBadwod!<br>!Rfødonotcare<br>INVALID<br>Valid<br>Valid<br>R85r!4L145<br>Valid<br>S3att!eWa<br>Valid<br>SONameHere<br>INVALID<br>Abc!23<br>INVALID<br>Format Lines for Report<br>Use the following format lines to produce correctly formatted output.<br>Header<br>print(

Extracted text: Password Validation Report Using the provided passwords.csv file, your report should look like the one below. Validate Passwords in Check File March2021 INVALID iudj8&neB09 MyDogWoof Valid INVALID mv3m959 INVALID ven1vidiv1c1Iulius INVALID 123456789 INVALID abcdefgcijk INVALID What#ItNOw INVALID windsofchange HelloMyNameIs INVALID INVALID 4584208 INVALID 4586300 INVALID Anniv&0629 Valid BDay@1955 BigBadwod! !Rfødonotcare INVALID Valid Valid R85r!4L145 Valid S3att!eWa Valid SONameHere INVALID Abc!23 INVALID Format Lines for Report Use the following format lines to produce correctly formatted output. Header print( "\n\n%62s" % "Validate Passwords in Check File\n" ) Detail Line Valid Passwords print( "%40s\tValid" % word) Invalid Passwords print( "%40s\t\t\tINVALID" % word ) Where "word“ is the name used to address individual entries in the List returned from buildList.

Jun 11, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here