PS00#
Prof Eatai Roth
DS325 F2025
Gettysburg College
Before downloading this Problem Set file#
Let’s set up a Git repository folder on your local computer. This folder will hold all of your assignments and projects for this class and will be linked to a repository that lives on Github.
Jupyter notebook review#
Notebooks comprise two kinds of cells:
Markdown - text annotation (like this cell).
Code - cells that will run code.
Some useful keyboard shortcuts:
SHIFT+RETURN (SHIFT+ENTER on PC) - runs a cell and moves focus to the next cell
Esc -> A - adds a cell above the current cell (-> means followed by)
Esc -> B - adds a cell below the current cell
Esc -> M - converts a cell to Markdown
Esc -> Y - converts a cell to Code
Kernels#
When you first run a cell of code, VS Code will prompt you to select a kernel. You can think of a kernel as a computational session and VS Code wants to know which version of Python you’d like to use to execute your code. It will present a list of installed Python distributions; you should select the one that has ‘Anaconda’ in the path.
The kernel also keeps track of all the variables you’ve created in the session. If you want to run your code from a clean slate, you can restart the kernel to clear all variables.
Assignment grading#
I’ll be using a package called Otter Grader to help automate the grading and feedback you get on assignments. We’ll see how Otter grader works below, but first, we must install the package.
%%capture
!pip install otter-grader
import otter
import matplotlib.pyplot as plt
grader = otter.Notebook()
Practice Problems#
Problem 1
Write a function named hello_blank
that takes as an input any string and returns a new string ‘Hello [input string]!’
...
Ellipsis
# grader.check("q1")
Problem 2
Create a DataFrame mirroring the table below and assign this to icecream_df
. Then group by the flavor
column and find the mean price for each flavor; assign this series to price_by_flavor
.
flavor |
scoops |
price |
---|---|---|
chocolate |
1 |
2 |
vanilla |
1 |
1.5 |
chocolate |
2 |
3 |
strawberry |
1 |
2 |
strawberry |
3 |
4 |
vanilla |
2 |
2 |
mint |
1 |
4 |
mint |
2 |
5 |
chocolate |
3 |
5 |
icecream_df = ...
price_by_flavor = ...
price_by_flavor
Ellipsis
# grader.check("q2a")
2b
Create a barplot of price_by_flavor
.
...
plt.show()
2c Per scoop, which flavor is most expensive?
Type your answer here, replacing this text.