Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python: Creating a Dictionary of Identifiers Understand the Application Sherlock Holmesacclaimed detective whose abilities are tauted as bordering on the fantastic was known for his

Python: Creating a Dictionary of Identifiers

Understand the Application

Sherlock Holmesacclaimed detective whose abilities are tauted as bordering on the fantastic was known for his astute ability to adopt disguise and use forensic science to solve the unsolvable.

Our task for this week is to wear our own Sherlock Holmes hat of sorts using our guise as a computer scientist to ferret out the unknown. The next time the tall tale of check is in the mail youll be able to step in to verify this statement for yourself as you use your own forensic science to solve the question if indeed that check, that phonecall, (i.e. that identifier) is in the mail (i.e. in the record log).

Specifically we will write a Python3 program that will read in a Python source file producing an index of all identifiers in that file. For each identifier, our solution intelligence will additionally print all lines in which the identifier occurs.

The Program Spec

Write a program that reads in a filename provided by the user, opens it and reads all of the lines. Create a dictionary to hold the line numbers for each valid identifier found. Your solution will need to process each line to determine whether a valid identifier exists on that line and if so, record both the line number and identifier found in the dictionary.

A valid identifier must be a string consisting of only letters, numbers and underscores. If a line contains an invalid identifier no record is made in the dictionary. If a line contains a valid identifier already recorded in the dictionary append the line number to the dictionary log of where the identifier was found.

Deliverable: yournameLab5.py Your source code solution and a copy of the run pasted into your source submission file. Be sure to comment out your run so that your .py file will still run in the grader test bed.

Input Error Checking: For simplicity a python file is provided to feed into your dictionary generator. The filename is t5.py provided in webAccess.

Test Run Requirements: Use the provided t5.py file as your test run validator.

Here are some other tips and requirements:

1. Keep provided test file intact

2. Use t5.py as your input test file to generate submission run output

3. Verify identifiers are valid; ignore if invalid

Here is a sample run:

apple: [1, 11]

art: [5]

----------------------------------------------------------------------------------

t5.py

apple 1 1 ball art dog & pen rat 4 apple 1@. carrot ! orange ant ant ant ball stick pen _ $a *** goodbye

--------------------------------------------------------------

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Inference Control In Statistical Databases From Theory To Practice Lncs 2316

Authors: Josep Domingo-Ferrer

2002nd Edition

3540436146, 978-3540436140

More Books

Students also viewed these Databases questions

Question

Summarize Koffkas contributions to gestalt psychology?

Answered: 1 week ago