Skip to content

Commit 1244feb

Browse files
committed
Add miniprojects
- Add miniprojects - Add book overview to intro - Add suggested progression to intro
1 parent 6728204 commit 1244feb

File tree

41 files changed

+1553
-23
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1553
-23
lines changed

404.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ title: Page Not Found
66

77
The link you followed may be broken, or the page may have been moved or renamed.
88

9-
Take me back to [PythonForLifeScientists.com](index.qmd)
9+
Take me back [home](index.qmd).

_freeze/algorithmic_thinking/index/execute-results/html.json

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"hash": "8ea37c7d87e3a4152523c56f0e8f3489",
3+
"result": {
4+
"engine": "jupyter",
5+
"markdown": "---\nauthor: \"Ryan M. Moore, PhD\"\ndate-modified: last-modified\ndate: \"2025-02-16\"\njupyter: python3\n---\n\n# Miniproject 1: Modeling Amoeba Population Growth {.unnumbered}\n\n_Note: To complete the miniproject, download the [quarto document](https://github.com/mooreryan/applied_python_programming/blob/main/miniprojects/amoebas/index.qmd) and complete any required sections._\n\n## Overview\n\nLet's build a fun simulation that models how populations of amoebas grow and change over time! We'll create a simplified version of their life cycle where these single-celled organisms can:\n\n- Grow or shrink randomly\n- Split into two when they get too big\n- Die if they become too small\n\nWhile this is a simplified model compared to real amoeba biology, it lets us explore some interesting population dynamics while practicing core programming concepts.\n\n### What You'll Need\n\nIn addition to Python 3 and Quarto, which you should have set up in Module 0, you will need to install [seaborn](https://seaborn.pydata.org/index.html), a package for statistical data visualization. Follow the instructions in this [installation guide](https://seaborn.pydata.org/installing.html) to get it set up.\n\n### Learning Goals\n\nBy completing this project, you will:\n\n- Practice breaking complex problems into smaller, manageable pieces\n- Get hands-on experience with loops and if/else logic\n- Learn to track data across multiple iterations\n- Create your first data visualization\n- Practice explaining your code and thought process\n\n## The Basic Rules\n\nYour amoeba population should follow these rules.\n\n### Starting conditions\n\n- Begin with 10 amoebas\n- Each amoeba starts at size 10\n\n### Each turn\n\n- Every amoeba randomly grows or shrinks between -2 and +2 units\n- If an amoeba gets smaller than 5 units, it dies\n- If an amoeba grows larger than 15 units, it splits into two amoebas, each half the size\n- Keep track of:\n - The total number of living amoebas (`population_history`)\n - How many amoebas died (`death_history`)\n - How many times amoebas split into two (`split_history`)\n\nWe'll store these measurements in three lists: `population_history`, `death_history`, and `split_history`. This will let us see how our population changes over time and create some interesting visualizations later.\n\n_Note: Using these exact variable names will ensure the plotting code works smoothly at the end of the project._\n\n### Ending the Simulation\n\nThe simulation runs until either:\n\n- 999 turns have passed, or\n- All amoebas have died\n\n## What to Include in Your Write-up\n\nYour project should include:\n\n- The simulation code itself\n- Well-commented code\n - Help your future self (and others) understand your thinking\n - Explain the \"why\" behind key decisions\n- A brief discussion of your implementation choices\n - What approaches did you consider?\n - Why did you choose your final solution?\n- Analysis of results\n - What patterns did you observe in the population over time?\n - Try changing some parameters (growth range, split/death thresholds, etc.)\n - How do different settings affect population survival?\n\n### Experiment!\n\nOnce you have a working simulation, try these variations:\n\n- Adjust the growth/shrink range\n- Change the split and death thresholds\n- Find settings that keep the population alive longer\n- What other parameters could you modify?\n\nAdd a short paragraph to your write-up discussing the results of your experiments.\n\n**Remember**: The goal is to learn and explore. There's no single \"right\" answer!\n\n## Helpful Code Examples\n\nHere are some building blocks to help you get started.\n\n### Keeping Track of Changes Over Time\n\nIn the amoeba simulation, you will need to monitor how total population, number of deaths, and number of splits change across turns. Here's a simple pattern that shows how to track these changes:\n\n::: {#105926bf .cell execution_count=1}\n``` {.python .cell-code}\n# This list will store our values at each step\nsum_history = []\n\n# This tracks our current total\nrunning_sum = 0\n\nfor number in range(5):\n # Update our running total by adding the new value\n running_sum += number\n\n # Save this step's total to our history\n sum_history.append(running_sum)\n```\n:::\n\n\nYou could think of `sum_history` like taking snapshots of your data at each moment in time. Each time through the loop, we update our current value (`running_sum`) and then save that snapshot to our history list. This pattern is useful when you need to look back at how your values changed throughout your simulation.\n\n### Generating Numbers in a Range\n\nIn this simulation, you will need to generate numbers within a range. Python makes this easy with the [`randint`](https://docs.python.org/3/library/random.html#random.randint) function from its `random` module. Think of it as setting up the minimum and maximum values you want, and letting Python pick random numbers within that range.\n\nHere's a simple example:\n\n::: {#de4ca743 .cell execution_count=2}\n``` {.python .cell-code}\nimport random\n\nfor _ in range(5):\n number = random.randint(-10, 10)\n print(number)\n```\n\n::: {.cell-output .cell-output-stdout}\n```\n-4\n9\n8\n-9\n10\n```\n:::\n:::\n\n\nThis code creates a list of 5 random whole numbers, where each number can be anywhere from -10 to 10 (including both -10 and 10), and then prints out the number. Every time you run this code, you'll get a different set of numbers. Try running the code block a few times to check.\n\n_Note: The value range in `radom.randint(a, b)` is inclusive, meaning both the lower bound (`a`) and upper bound (`b`) can appear in your results._\n\n### Managing Your Amoeba Population\n\nA key piece of this simulation is handling the changing population of amoebas over time. It's a good idea to store our amoebas in a Python list, which works like a container that can hold multiple items. Each turn, we need to check each amoeba against our rules to determine if it:\n\n- Survives to the next turn\n- Dies and gets removed from the population\n- Splits into multiple amoebas\n\nHere's a straightforward way to handle these population changes. Instead of trying to modify our original population list directly (which can get messy), we'll create a new list for the survivors each turn.\n\nHere's a simple example to illustrate this concept:\n\n::: {#4f68b343 .cell execution_count=3}\n``` {.python .cell-code}\namoebas = [1, 2, 3, 4, 5, 6]\nprint(\"Starting population:\", amoebas)\n\n# Create an empty list to hold the survivors\nsurvivors = []\n\n# Check each amoeba against our survival rules\nfor amoeba in amoebas:\n # In this example, amoebas with even-numbered sizes survive\n if amoeba % 2 == 0:\n survivors.append(amoeba)\n # Amoebas with odd-numbered sizes \"die\" by not being added to survivors\n\n# Update our population with the survivors\namoebas = survivors\nprint(\"Population after 1 turn:\", amoebas)\n```\n\n::: {.cell-output .cell-output-stdout}\n```\nStarting population: [1, 2, 3, 4, 5, 6]\nPopulation after 1 turn: [2, 4, 6]\n```\n:::\n:::\n\n\nThis approach is particularly useful when embedded in a larger loop that tracks multiple turns. Each turn, you start fresh with a new survivors list, apply your rules, and then update the population accordingly.\n\nWhile Python offers several ways to accomplish this task, this method is particularly clear and reliable. It gives you complete control over which amoebas make it to the next generation and makes it easy to add more complex survival rules later.\n\n## Simulation\n\n### Simulation Code\n\n::: {#4a3b2bee .cell execution_count=4}\n``` {.python .cell-code}\n# Write your simulation code here!\n```\n:::\n\n\n### Visualizing Your Simulation Results\n\nLet's create a graph to see how your amoeba population changed over time! We'll use a Python library called seaborn to make a clear, professional-looking line plot that shows the total population, deaths, and splits at each turn of the simulation.\n\nHere's the code to create the visualization:\n\n```python\nimport seaborn as sns\n\n# Set up the default seaborn style\nsns.set_theme()\n\n# Create a line plot showing all three metrics\nplot = sns.relplot(\n data={\n \"Population\": population_history,\n \"Deaths\": death_history,\n \"Splits\": split_history,\n },\n kind=\"line\",\n)\n\n# Label the axes\nplot.set_axis_labels(\"Turn\", \"Amoeba Count\")\n```\n\nIf you used different variable names to track your data (instead of `population_history`, `death_history`, or `split_history`), simply replace those names in the code above with your variable names.\n\nThis visualization will help you spot patterns in your simulation, like population booms and crashes, or how deaths and splits relate to each other. Don't worry if some of the plotting code looks unfamiliar -- we'll dive deeper into data visualization with seaborn in future lessons!\n\n## Analysis\n\nWrite your analysis text here!\n\n",
6+
"supporting": [
7+
"index_files"
8+
],
9+
"filters": [],
10+
"includes": {}
11+
}
12+
}

_freeze/miniprojects/gene_expression/index/execute-results/html.json

Lines changed: 12 additions & 0 deletions
Large diffs are not rendered by default.

_freeze/miniprojects/read_qc/index/execute-results/html.json

Lines changed: 12 additions & 0 deletions
Large diffs are not rendered by default.

_freeze/object_oriented_programming/index/execute-results/html.json

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

_quarto.yml

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,26 @@ book:
1919

2020
# Content
2121
chapters:
22-
- index.qmd
23-
- basics/index.qmd
24-
- collections/index.qmd
25-
- algorithmic_thinking/index.qmd
26-
- understanding_functions/index.qmd
27-
- text: "Object-Oriented Programming"
28-
href: object_oriented_programming/index.qmd
29-
- errors_exceptions/index.qmd
30-
- text: "Exploratory Data Analysis"
31-
href: exploratory_data_analysis/index.qmd
32-
- text: "Statistics & Modeling"
33-
href: stats_models/index.qmd
34-
- io_files_contexts/index.qmd
22+
- part: Chapters
23+
chapters:
24+
- index.qmd
25+
- basics/index.qmd
26+
- collections/index.qmd
27+
- algorithmic_thinking/index.qmd
28+
- understanding_functions/index.qmd
29+
- text: "Object-Oriented Programming"
30+
href: object_oriented_programming/index.qmd
31+
- errors_exceptions/index.qmd
32+
- text: "Exploratory Data Analysis"
33+
href: exploratory_data_analysis/index.qmd
34+
- text: "Statistics & Modeling"
35+
href: stats_models/index.qmd
36+
- io_files_contexts/index.qmd
37+
- part: Miniprojects
38+
chapters:
39+
- miniprojects/amoebas/index.qmd
40+
- miniprojects/gene_expression/index.qmd
41+
- miniprojects/read_qc/index.qmd
3542
appendices:
3643
- part: Basics
3744
chapters:

algorithmic_thinking/index.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ date: "2025-02-18"
55
jupyter: python3
66
---
77

8-
# Algorithmic Thinking
8+
# Algorithmic Thinking {#sec-algorithmic-thinking}
99

1010
## Overview
1111

index.qmd

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,53 @@ This resource serves as an introduction to computational and algorithmic thinkin
88

99
## Book Structure
1010

11-
The material in this online textbook has been used to teach a one semester introduction Python programming to life scientists. The nine numbered chapters (Basics through I/O, Files, & Contexts) made up the majority of the course material. You will also see various appendices. These include practice problems and solutions, and answers to "Stop & Think" questions posed throughout the textbook. Additionally, appendices include some short treatments of useful topics like regular expressions (@sec-regex).
11+
The material in this online textbook has been lightly adapted from material used to teach a one semester introduction Python programming to life scientists.
12+
13+
The material includes:
14+
15+
- Introduction
16+
- Setup instructions (coming soon)
17+
- Nine numbered chapters ("Basics" through "I/O, Files, & Contexts") that make up the bulk of the learning material
18+
- Three assignments (coming soon)
19+
- Three miniprojects
20+
- Various appendices with
21+
- Practice problems
22+
- Solutions to practice problems
23+
- "Stop & Think" Solutions
24+
- Short coverage of useful topics like regular expressions
25+
26+
### How to Approach the Material
27+
28+
For each chapter, you should download the Quarto notebook, and code along. That is, whenever you see code samples, play around with them, try to extend them or break them in various ways, observe the error messages you get, etc. Quarto docs provide a nice playground for exploring the code, so be sure to use them.
29+
30+
Some chapters have additional practice problems or "Stop & Think" sections. You should always attempt to answer the "Stop & Think" questions before continuing on with the chapter. For chapters with practice problems, I suggest you do at least some of them until you feel comfortable. Make sure you come back to previous chapter's practice problems from time to time while you're learning for review.
31+
32+
Assignments and Miniprojects are there to test your learning. In general, they will have lots of helpful tips and tricks to get you started. If you're more advanced, you may think there is too much hand-holding in these documents. Remember that this material is geared towards life scientists with no prior programming experience. If that doesn't describe you, give the assignments and miniprojects a try without looking at the hints.
33+
34+
### Suggested Progression
35+
36+
This is roughly the progression we followed in the course:
37+
38+
- [Chapter @sec-basics]
39+
- Assignment 1: Getting Started with Python (coming soon)
40+
- [Chapter @sec-collections]
41+
- [Miniproject 1: Modeling Amoeba Population Growth](miniprojects/amoebas/)
42+
- [Chapter @sec-algorithmic-thinking]
43+
- [Chapter @sec-functions]
44+
- Assignment 2: Functions, Algorithms, & Objects (coming soon)
45+
- [Chapter @sec-oop]
46+
- [Chapter @sec-errors-exceptions]
47+
- [Miniproject 2: Gene Expression Analysis](miniprojects/gene_expression/)
48+
- [Chapter @sec-eda]
49+
- [Chapter @sec-stats-models]
50+
- Assignment 3: Data Science (coming soon)
51+
- [Chapter @sec-io-files-contexts]
52+
- [Miniproject 3: Read Quality Control](miniprojects/read_qc/)
53+
54+
## Notes
55+
56+
- Not all chapters have additional practice problems or "Stop & Think" sections
57+
- While the assignments are written, they haven't yet been uploaded to the site
1258

1359
## License
1460

0 commit comments

Comments
 (0)