Making with Code

Summary Statistics Lab #

In this lab, you will practice using Jupyter Notebook and write algorithms to calculate statistics about datasets.

[0] Pseudocode #

How do you make sense of lots of data? You can summarize it with statistics!

Calculate The Central Tendency #

When you have a ton of data, you might want to find one number to summarize the data. How about the middle?

Here are three ways to find the middle:

  • Mean: the average of a list of numbers
  • Median: the middle number in a sorted list of numbers
  • Mode: value that appears most frequently in a data set

In this lab, we will write the algorithms to find the median, mean, and mode of a list of numbers. Before jumping into the Python code, let’s write the pseudocode so we can be sure our algorithm works as intended.

✏️ In groups, work through the Summary Stats Lab Worksheet.
✅ CHECKPOINT:

Check in with a teacher before moving onto the translating your pseudocode into Python code.

[1] Translating Pseudocode #

[Setup] #

Now that you are confident in your algorithms, try to translate them into Python code.

💻 Starter code for the lab is provided in the lab-sumstats repo.

cd cs9/unit_01
git clone https://github.com/the-isf-academy/lab-sumstats-YOUR-GITHUB-USERNAME.git

[sumstats.ipynb] #

💻 Open the sumstats.ipynb file by typing jupyter notebook in your Terminal. Be sure to read cell by cell, and follow along with instructions.

Each person should write their own code, but you can work together to complete each function.

[Deliverables] #

⚡✨

For this lab, you should submit the following…

  • Your sumstats.ipynb file with code for each of the following functions:
    • calculate_mean()
    • calculate_median()
    • calculate_mode()

Also be sure to hand in your Summary Stats Lab Worksheet.


[2] Solutions #

Below are correctly ordered pseudocode and code solutions for each of the required functions.

💻 Use the solutions to fill in your sumstats.ipynb file.

[Mean] #

[Median] #

[Mode] #

create_counts_dict() #

caculate_mode() #