Question

Task (Python) A lot of police investigations start off by examining where the potential suspects was...

Task (Python)

A lot of police investigations start off by examining where the potential suspects

was at the time of the crime. This is often done by asking phone companies to

provide lists of all mobile phones that was in the area where the crime was

committed around the time when it was committed. If there is only one crime scene

this is not a big problem but if there are several crime scenes then the task of cross

referencing the lists gets quite tedious. To combat this the local police department

has decided to automate the process by creating a script that automatically does

most of the work for them.

The script shall work as follows:

1- Start the script

2- Provide one or more paths to files with phone numbers

3- The script finds out what phone numbers occur in all files

4- The script looks up who owns the phone numbers found

5- The script displays the found names

To break it all down a little bit further this is what should happen during each step.

1. When starting the script, a path to a file that contains the

mapping between name and number shall be given as a

command line argument. This file shall contain a pickled

dictionary on the following format {‘0709-12345’: ‘Anna’}.

2. To be able to provide an arbitrary number of files a menu is

needed. The menu shall have the following options: 1. Add

file and 2. Calculate. All file paths added shall be saved in a list

for later use.

3. This step is part of the menu option 2. Calculate. The script

shall cross reference the numbers in all the files provided and

create a Set with the ones that occur in all files. The files with

the phone numbers store one phone number per line and is

saved as a regular text file.

4. This step is part of the menu option 2. Calculate. Using the Set

of found numbers the script looks up the owner’s names using

the file sent as a command line argument. The names shall be

saved in a list.

5. All the found names located in the set from Step 4 is displayed

on the screen.

To solve task the student must make use of a main function and also implement the

following functions:

display_menu ()

This function shall display the following menu on screen:

1. Add file

2. Calculate

cross_reference (files)

The parameter files shall be a list of filenames (full path). The files shall be files

containing one phone number per line. The function shall create, and return,

a Set containing all the phone numbers that occurs in all files.

map_numbers_to_names (numbers, filename)

This function shall match each number from the Set numbers to a name and store

the names in a list. To accomplish this, the function shall use a dictionary that is

loaded (using pickle) from the file filename. The dictionary shall use the format

{‘0709-12345’: ‘Anna Karlsson’}. If a number can not be found in the dictionary it

shall be listed as Unknown with the phone number attached, like can be seen in this

example: Unknown (0709-11111). The function shall return the list with the names

and/or unknown tags.

display_suspects (names)

As the name of the function suggests this function shall display the names of all

suspects sent to the function as a list of strings. The format shall be as shown here:

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

The following persons was present on all crime scenes:

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

Max Olsson

Zara Walthersson

Unknown (0703-23464)

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

If the list sent as a parameter is empty the following message shall be shown:

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

The following persons was present on all crime scenes:

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

No matches

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

Make sure to include error handling that displays the following message to the user

if the file given as command line arguments or the files specified while running the

script is not valid:

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

Error: There was a problem with at least one of the files.

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

Hint: These files (owners, crime scene 1 , crime scene 2 and crime scene 3) and can be used     as an example of how the files with owner mapped to phone

numbers and the lists from the crime scenes might look like.

0 0
Add a comment Improve this question Transcribed image text
Request Professional Answer

Request Answer!

We need at least 10 more requests to produce the answer.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the answer will be notified once they are available.
Know the answer?
Add Answer to:
Task (Python) A lot of police investigations start off by examining where the potential suspects was...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Below is my code please help me edit it so in the beginning it ask for Press any key to start Tas...

    below is my code please help me edit it so in the beginning it ask for Press any key to start Task n, where n is the task number (1, 2, or 3,4). I already wrote the code for the 4 task. Also please write it so when 1 code is finish running it return to the prompt where it ask to run another task #task 1 list1 = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9','.',',','?'] morse = ['.-','-...','-.-.','-..','.','..-.','--.','....','..','.---','-.-','.-..','--','-.','---','.--.','--.-','.-.','...','-','..-','...-','.--','-..-','-.--','--..','-----','.----','..---','...--','....-','.....','-....','--...','---..','----.','.-.-.-','--..--','..--..'] inp = input("Enter original text : ")...

  • Python Programming QUESTION 16 Which of the following is an example of a Keyword in Python?...

    Python Programming QUESTION 16 Which of the following is an example of a Keyword in Python? elif class for All of the above QUESTION 17 Which of the following is not an acceptable variable name in Python? 2ndVar $amount Rich& ard None of the above are acceptable variable names QUESTION 18 The number 1 rule in creating programs is ___________________- Write the code first Think before you program Let the compiler find you syntax errors There are no rules just...

  • Could anyone help add to my python code? I now need to calculate the mean and...

    Could anyone help add to my python code? I now need to calculate the mean and median. In this programming assignment you are to extend the program you wrote for Number Stats to determine the median and mode of the numbers read from the file. You are to create a program called numstat2.py that reads a series of integer numbers from a file and determines and displays the following: The name of the file. The sum of the numbers. The...

  • please do a and b Lab Exercise 9 Assignment Overview This lab exercise provides practice with...

    please do a and b Lab Exercise 9 Assignment Overview This lab exercise provides practice with dictionaries of lists and sets in Python. A. Write a program using Dictionaries of lists Consider the file named "lab9a.ру" Given two files named exactly continents. txt and cities.txt (no error checking of the file name is needed) of continents, countries and cities. Write a program to read continents, countries and their cities, put them in a nested dictionary and print them (no duplicates...

  • Help needed with Python 3: Dictionaries and Sets. The problem is one that asks the user to create...

    Help needed with Python 3: Dictionaries and Sets. The problem is one that asks the user to create a completed program that prompts the user for the name of a data file, and reads the contents of that data file, then creates variables in a form suitable for computing the answer to some questions. The format should be in the same manner as the attached .py file. All subsequent assignment details (.py and .csv files) can be found at this...

  • NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions...

    NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...

  • NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions...

    NOTE: LANGUAGE IS PYTHON CS160 Computer Science Lab 17 Objectives Work with dictionaries Work with functions Work with files Overview This lab will have you store the birthdays for a group of people. This program will store the information with the focus on the date of the month and not on the individual. The point of this program is to be able to see who has a birthday on a given day or to create a table of birthdays, in...

  • This script will create a dictionary whose keys are all the directories listed in thePATH system...

    This script will create a dictionary whose keys are all the directories listed in thePATH system variable, and whose values are the number of files in each of these directories. The script will also print each directory entry sorted by directory name. The script will use the following five functions to get the required results get_environment_variable_value() get_dirs_from_path() get_file_count() get_file_count_for_dir_list() print_sorted_dictionary() get_environment_variable_value() The header for this function must be This function must accept a shell variable as its only parameter The...

  • 1. Explain the difference between the /etc/profile and the ~/.bash_profile file. Which one is executed first?...

    1. Explain the difference between the /etc/profile and the ~/.bash_profile file. Which one is executed first? 2. Edit your .bash_profile file as follows: 1. Welcome the user 2. Add your home directory to the path if it is not there 3. Set erase to the Backspace key using stty. 4. Type source .bash_profile. What is the function of the source command? 3. What is the default primary prompt? 1. Change the prompt to include the time of day and your...

  • Your mission in this programming assignment is to create a Python program that will take an...

    Your mission in this programming assignment is to create a Python program that will take an input file, determine if the contents of the file contain email addresses and/or phone numbers, create an output file with any found email addresses and phone numbers, and then create an archive with the output file as its contents.   Tasks Your program is to accomplish the following: ‐ Welcome the user to the program ‐ Prompt for and get an input filename, a .txt...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT