1. We’re experimenting with platypus (platypi?). During the breeding season, each platypus will lay a certain number of eggs. We want to model the platypus and keep track of how many eggs they’ve laid each season.

Design a class, Platypus, that takes the name of the platypus and a list containing the number of eggs laid each season. For example,

``````>>> perry = Platypus("perry", [3, 2, 4, 1, 2])\
>>> perry.name
"perry"
...
``````
2. Expand the Platypus class, giving it three methods:

`total_fecundity`, which returns the total number of eggs laid `breeding_seasons`, which returns the number of breeding seasons in which the platypus laid at least 1 egg `lay_eggs`, which adds the number of eggs laid to the end of the list.

It should look something like this:

``````>>> perry = Platypus("perry", [3, 2, 4, 1, 2])
>>> perry.breeding_seasons()
5
>>> perry.total_fecundity()
12
>>> perry.lay_eggs(2)
>>> perry.total_fecundity()
14
``````
3. We know that platypuses can lay up to three eggs each season. Starting with the most basic assumption that each number of eggs is equally likely (including zero), model the reproductive dynamics of a group of three platypuses.

Create three Platypus objects, choosing a name and an initial number of eggs for a season for each. Simulate 10 seasons worth of egg laying. For each season for each platypus, randomly choose a number of eggs from zero to three and add it to the list of the number of eggs laid. Once the simulation is finished print out the name, total fecundity, and number of breeding seasons for each platypus based on the following example:

Billy laid a total of 10 eggs in 5 successful breeding seasons.

4. Here’s the platypus fecundity data from our first experiment (using the simple Platypus class that we built in problems 1 and 2), stored conveniently as a Python list:

``````[Platypus("perry", [3,2,4,1,2]),
Platypus("quacker", [100,1,3,1,2]),
Platypus("fishface", [0,1,3,1,2,1]),
Platypus("professor quackington", [2,1,4,5,7]),
Platypus("bartholomew beavertail", [0,1,3,1,0,0,2]),
Platypus("syd", [3,1,3,1,3,5,5,2,1,3]),
Platypus("ovide", [2,0,10,0,0,0,0,0,0]),
Platypus("hexley", [3,1,2,3,1,0,0,1,1]),
Platypus("supafly", [19,1,2,1,0,0,0,1])]
``````

Unfortunately, this data was collected by undergraduates, so it contains some obvious clerical errors. Being an expert in platypus life history, you reason that it’s unlikely that a platypus would lay more than an average of 3 eggs per breeding season.

Write a list comprehension that returns the names of individuals that laid more than 3 eggs per breeding season, on average.

5. There are many diverse sources of biological data in the modern world, but not all of them are nicely cultivated into well structured data. For a project you’re working on you need a list of all of the rodent species in the world. You find a great list of rodents by following the first link on a Google search for List of Rodents.

Unfortunately it’s in HTML and scraping HTML is generally considered to be a bit of a nightmare. Fortunately it’s a Wikipedia article and Wikipedia has a nice feature to let us see the source code (or wiki markup) that is used to build the HTML. This is same as what we would see if we clicked on the Edit tab of the article, but accessible in a simple text file. This can be done useing the general url:

http://en.wikipedia.org/w/index.php?title=PAGETITLE&action=raw

where PAGETITLE is replaced with the actual title of the page.

Download the wiki markup and write a short script using regular expressions that extracts the list of all latin binomials from the page. Export this list as a text file, one species per line, with genus and species separated by a comma.

6. This is a follow up to the Regular Expressions 1 problem.

Once you figured out how to extract the latin binomials from a Wikipedia page that, to be generous, wasn’t exactly the most consistently formated thing you’d ever seen before, you realize that your Python Kung Fu has gotten pretty strong over the last few months*. So, you decide to push yourself a little harder and see how far you can get with this Wikipedia rodent list in another hour or two. Instead of getting just the latin binomial for each species you decide to also get the family so that each line of the results is family, genus, species (we don’t care about sub families, sub genera, etc.). And, because transfering things between databases and programming languages using text files is for rookies, novices, and newbs, you decide to skip the whole csv thing and move all of the resulting information straight into an SQLite database.

When you’re done with this assignment, commit the raw data file and the Python code to your repository. There’s no need to commit the database because your code will create it when executed.

Note: It is not uncommon for this type of programming euphoria driven confidence and excitement to be brutally shattered by the very next thing you try… so…