Food Webs or the Zombie Apocalypse

Authors: Ben Stephenson (ben.stephenson@ucalgary.ca) and Jonathan Hudson (jwhudson@ucalgary.ca)

Description:

Food webs represent the feeding relationships between organisms in an ecosystem. When represented as a directed graph, each organism is a vertex. Edges connect organisms where one preys on the other. The same representation can be used to model the spread of a zombie contagion between individuals in a population, where vertices represent individuals and edges represent reported contact between the individuals.

This document describes two forms of the same assignment. Both versions have the students complete identical tasks, in one case on the organisms in an ecosystem, and in the other case on the individuals in a population facing a zombie apocalypse. While the tasks students completed were identical in each of the assignments the difference in how the assignment tasks were presented obscured this fact from the students. This extended the life of the assignment by reducing the utility of any materials posted by students from previous semesters because the terms used to describe the tasks were different in the new context.

The specific tasks required of the students in each version of the assignment were:

In addition, the Zombie version of the assignment asked students to identify individuals that were neither patient zeros nor potential zombies. The corresponding task (identifying organisms that are neither apex predators nor producers) was not included in the food web version of the assignment but could easily be added.

The food web version of this assignment has been used with approximately 2,000 students enrolled in a CS1 course (for non-CS majors) in at least 8 terms. The actual student handout from the most recent offering in the fall 2018 term is available in both PDF and Word format. The infectious disease version of this assignment has been used with approximately 350 students enrolled in the same CS1 course in a single term. That version of the handout is also available in PDF and Word formats.

Metadata

Summary This assignment asks students to create a program which analyzes food web data, or equivalently, asks students to analyze contacts between infected individuals. In either case the individual parts of the assignment ask students to identify organisms or individuals with particular properties such as being a producer or being a patient zero.
Audience Each variation of this assignment was the final assignment in a programming intensive CS1 course (for non-majors) that takes an objects-late approach. It can be used whenever students are being introduced to file I/O and exceptions, and have previous experience with dictionaries, lists, strings and functions. The food web version of the assignment was specifically crafted to appeal to non-majors by showing them how introductory programming could help them build tools to analyze data in their academic discipline of interest. The contact tracing version of the assignment was of particular relevance to all students because it was used during the COVID-19 pandemic.
Difficulty Students found this assignment to be moderately difficult. The flexibility to tackle all but the first portion of the assignment in any order reduced the difficulty of the assignment because students could, if necessary, abandon one part of the assignment and tackle another while waiting for an opportunity to seek help. We gave the students between 2 and 3 weeks to complete the assignment and our impression was that this was appropriate.
Topics The assignment focuses on lists and dictionaries, and to a lesser extent, file I/O, exceptions, strings and functions. Students also need to write loops and if statements which we assume they are comfortable with from prior assignments that focused on such.
Strengths Having two different versions of the assignment that appear to be unique but actually require students to solve the same problems with different "window dressing" extended the life of the assignment and allowed the effort put into creating grading schemes to be amortized over more offerings of the course. Additional ways of presenting this same series of tasks are included in the Variants section.

The data analysis performed is non-numeric and demonstrates the utility of computer science to non-majors for solving problems that might not fit their preconceptions about the kinds of problems that computers are able to solve.

The data being analyzed in the food web assignment is real data from another discipline that does not have to be simplified or arbitrarily restricted.

Students are able to see that they are making progress, with each part of the assignment performing an additional analysis and immediately displaying an additional result. It is not an assignment where you don't really see much progress until the final piece is put into place allowing everything to work together. We believe that being able to see their progress as each part of the assignment is completed benefits students by providing a more immediate sense of accomplishment.

Weaknesses We have frequently noticed that students confuse returning a value from a function and printing a value within a function. While the Zombie version of the assignment required students to identify the individuals inside the function body and then print them in the main program we noticed that numerous students erroneously printed the result inside the function. The food web version of the assignment did not include any requirements related to the location where results were printed, and as such, also didn't help students understand the difference between printing a result and returning it from a function.
Dependencies We provided students with a function that formatted lists, which is available in formatList.py, to slightly reduce the difficulty of the assignment.

Our students created their solutions in Python. However this assignment could easily be adapted to Java (or very likely any other language used to teach CS1).

Variants This document includes two variations of the assignment, one of which describes the tasks students need to perform as operations on food webs, and another which describes the same tasks as operations on contact tracing data for an infection that turns people into zombies. One could imagine other presentations of the same problem, such as analyzing friend relationships in a social network, the relationship between computers and routers that make up a computer network, or even who tagged whom in a game of tag between children.

Our students were asked to acquire the input file name from the command line and to perform some minimal exception handling. These requirements could easily be removed so that this assignment could be used in courses that don't cover those topics.

The difficulty of the assignment could be increased by requiring students to handle errors in the data files such as blank or incorrectly formatted lines. Students could also be asked to write the function that we provided for formatting lists nicely instead of having it provided to them.

Our handouts specifically told students to use lists to store the collections of organisms or indivudals identified in each part of the assignment. The assignment could be modified to use sets instead of lists, or leave this choice to the students. Similarly, we provided an iterative algorithm for finding the heights of the organisms. Students could, instead, be provided with a recursive algorithm, or be left to develop their own algorithm.

Teaching Notes While not included in the assignment handouts, one of the instructors found it particularly helpful to communicate the requirements to students in a visual manner when introducing the assigment in class. This involved drawing one of the data sets as a directed graph and then circling the sub-groups that needed to be identified for each part of the assignment. Presenting the data visually also allowed the instructor to hint at data structures like trees, forests and graphs that students will encounter in later computer science courses.

Food Web Data Files and Expected Output

SimpleFoodWeb.txt
SimpleFoodWeb_Output.txt

AquaticFoodWeb.txt
AquaticFoodWeb_Output.txt

GrasslandFoodWeb.txt
GrasslandFoodWeb_Output.txt

MixedFoodWeb.txt
MixedFoodWeb_Output.txt

AnotherFoodWeb.txt
AnotherFoodWeb_Output.txt

TerrestrialFoodWeb.txt
TerrestrialFoodWeb_Output.txt

Contact Tracing Files and Expected Output

DataSet0.txt
DataSet0-out.txt

DataSet1.txt
DataSet1-out.txt

DataSet2.txt
DataSet2-out.txt

DataSet3.txt
DataSet3-out.txt

DataSet4.txt
DataSet4-out.txt

DataSet5.txt
DataSet5-out.txt