CPSC 217: Introduction to Computer Science for Multidisciplinary Studies I Assignment 4: Contact Tracing Weight: 7% Collaboration Discussing the assignment requirements with others is a reasonable...

Assignment requirements are in the file


CPSC 217: Introduction to Computer Science for Multidisciplinary Studies I Assignment 4: Contact Tracing Weight: 7% Collaboration Discussing the assignment requirements with others is a reasonable thing to do, and an excellent way to learn. However, the work you hand-in must ultimately be your work. This is essential for you to benefit from the learning experience, and for the instructors and TAs to grade you fairly. Handing in work that is not your original work, but is represented as such, is plagiarism and academic misconduct. Penalties for academic misconduct are outlined in the university calendar. Here are some tips to avoid plagiarism in your programming assignments. 1. Cite all sources of code that you hand-in that are not your original work. You can put the citation into comments in your program. For example, if you find and use code found on a web site, include a comment that says, for example: # the following code is from https://www.quackit.com/python/tutorial/python_hello_world.cfm. Use the complete URL so that the marker can check the source. 2. Citing sources avoids accusations of plagiarism and penalties for academic misconduct. However, you may still get a low grade if you submit code that is not primarily developed by yourself. 3. Discuss and share ideas with other programmers as much as you like, but make sure that when you write your code that it is your own. A good rule of thumb is to wait 20 minutes after talking with somebody before writing your code. If you exchange code with another student, write code while discussing it with a fellow student, or copy code from another person’s console, then this code is not yours. 4. Collaborative coding is strictly prohibited. Your assignment submission must be strictly your code. Discussing anything beyond assignment requirements and ideas is a strictly forbidden form of collaboration. This includes sharing code, discussing code itself, or modelling code after another student's algorithm. You can not use (even with citation) another student’s code. 5. We will be looking for plagiarism in all code submissions, possibly using automated software designed for the task. For example, see Measures of Software Similarity (MOSS - https://theory.stanford.edu/~aiken/moss/). 6. Remember, if you are having trouble with an assignment, it is always better to go to your TA and/or instructor to get help than it is to plagiarize. Late Penalty Late assignments will not be accepted. Goal Writing a well-structured program with dictionaries, command line arguments, file I/O, and exception handling. Technology Python 3 Submission Instructions Your completed program must be submitted electronically. Use the Assignment 4 drop box in D2L for the electronic submission. Description In this assignment you will analyze fictious contact tracing data. This contact tracing data is one- directional, meaning certain people will have a record of contacting others after they tested positive. In order to do this, you will need to load an indicated data file storing contact tracing data. You will then store this data in dictionary and list data structures. These data structures will then be used to identify the relationship between the individuals in the data. Each of the parts 2 through to 7 should be implemented via a function which returns a list in the case of parts 2 through 6 or returns a dictionary for part 7. This function should examine a dictionary parameter, which holds the input file data, and returns the information that fulfills the requirements of that part of the assignment. You program will then print the information returned using print() commands. The reading of arguments, file handling, the Part 1 code, and the printing from the remaining parts can all happen in a single main function. You are welcome to use more functions if you desire, but you should have at least this minimal structure. File Format The information is stored in CSV (comma separated value) files. Example files (as well as your assignment’s expected output for each file) are posted on the course website. Each file ends with the .txt extension. (Typically, CSV files end with the .csv extension but many operating systems by default open these files in a spreadsheet program like Excel and when saving them will change their contents in a way that disrupts this assignment. Please don’t open these files in such a program, and don’t alter them in any way. You can open them in a text editor to see their contents.) You will need to implement the use of command line argument reading to get the filename to open each time your program is executed. Ex. python CPSC217F20A4.py DataSet1.txt Each line in the file will be of the form ,,,..., , are placeholders for specific people. Each line will always begin with exactly one person, followed by 1 or more other people. For example, lines in the file could be Jonathan, Alice, Bob or Carol, Alice Note the names may include a mixture of upper and lowercase letters and may also include spaces. The end of a name is indicated by the comma separators. In order to make the files easier to work with you can assume that there will not be any spaces immediately before or after any of the commas. Part 1: Who did each sick person have a record of contact with? Your first task is to list everybody that each person had contact with using nice formatting. For example, if your file contains the line: Jonathan, Alice, Bob then you should output a single line for Jonathan that reads Jonathan had contact with Alice and Bob There are two parts to this printing. First is the name of the person for which we were printing out their contact record. Then in between are the words ‘had contact with’. Finally, what follows is a formatted list of the people contacted by the first person. Notice that commas appear after all items except the last and second last items, and that the word “and” appears between the last and second last items. You will be graded on correctly following this layout, but I have provided a module formatList.py that includes a function that will do the formatting for you – all you need to do is import the function and call it. You can import this python file like you have SimpleGraphics.py previously and call the function formatList(yourList) to produce a string version of your listed formatted as required above. In order to complete this and subsequent tasks you must load all of the data from the input file into a dictionary that describes the contact relationship. The keys in the dictionary will by the names of the first sick person. The values in the dictionary will be lists, where each element in the list is the name of a person the sick person had contact with. The output for Part 1 for DataSet1.txt should be: Contact Records: Bob had contact with Carol, Leanne, Mark, Paul and Will Carol had contact with Leanne and Mark Farley had contact with Paul Leanne had contact with Sarai Larry had contact with Carol, Leanne, Mark and Will Mark had contact with Philip and Zach Paul had contact with Zach Will had contact with Leanne and Mark Zach had contact with Philip Note: I have displayed my output in sorted order by using Python’s sorted function. However, the order is not required. You’ll receive full credit as long as all of the records are identified correctly. Please remember to print the header Contact Records before your lines. Part 2: Identify the Possible Patient Zero(s) If we consider the input file to only consist of contact tracing records where we know everyone tested positive before contact their contact record list then we can track back the path of likely infection to what we will call patient zero(s). One way to think of patient zero(s) is that they are people who do not appear in anyone’s contact record list. After the Part 1 listing your program should continue and list the patient zero(s) for the input data with the appropriate heading. Hint: Patient zero(s) had contact with are those people that are keys in the dictionary that do not appear in any of the contact lists. The output for Part 2 for DataSet1.txt should be: Patient Zero(s): Bob, Farley and Larry Part 3: Identify the Potential Zombies We will define a potential zombie to be any person that might be infected but we don’t know yet. That is any person that doesn’t appear as sick, i.e. a first entry in a contact record in the file. The output from your program should continue by displaying all of the potential zombies with an appropriate heading. A potential zombie will occur in the list of a sick person, but not occur as a sick person itself. There should be no duplicates in this list. The output for Part 3 for DataSet1.txt should be: Potential Zombies: Philip and Sarai Part 4: Identify Species That Are Neither Patient Zero(s) or Potential Zombies People that fulfill this requirement are all the remaining people that you did not list in Part 2 of part 3. You should use the information returned by the functions created by these two parts to only add names that were not potential zombies and were not patient zero(s) to your list to return. The output for Part 4 for DataSet1.txt should be: Neither Patient Zero or Potential Zombie: Carol, Leanne, Mark, Paul, Will and Zach Part 5: Identify the Most Viral People We will define the most viral people as the people who likely infected the greatest number of other organisms in the data set. Identify and display all of the most viral people under an appropriate heading. The output for Part 5 for DataSet1.txt should be: Most Viral People: Bob While DataSet1.txt has only one of these other inputs may have several viral individuals, who infected the same amount of people. When that situation occurs, your program should display all of these at the same quantity. Part 6: The Tastiest
Dec 06, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here