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.

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

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
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.
Transcribed Image 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
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.
Transcribed Image 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.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 5 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar 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