← return to practice.dsc10.com
Instructor(s): Janine Tiefenbruck, Peter Chi
This quiz was administered in-person. Students were allowed one page of double-sided handwritten notes; students were not allowed to use the DSC 10 Reference Sheet. Students had 20 minutes to work on the quiz.
This quiz covered Lectures 1-5 of the Fall 2026 offering of DSC 10.
Note (groupby / pandas 2.0): Pandas 2.0+ no longer silently drops columns that can’t be aggregated after a groupby, so code written for older pandas may behave differently or raise errors. In these practice materials we use .get() to select the column(s) we want after .groupby(...).mean() (or other aggregations) so that our solutions run on current pandas. On real exams you will not be penalized for omitting .get() when the old behavior would have produced the same answer.
Coleman decides that tutoring DSC 10 is not lucrative enough to support his extravagant lifestyle, so he decides to open up a sushi restaurant called Coleman’s Catch.
The DataFrame menu has a row for each menu item available at Coleman’s Catch. A few rows are shown below, but there are additional rows not shown. The "Name" of the menu item is in the index (string), and the columns are "Type" (string), "Price" in dollars (float), number of "Pieces" (int) per order, and average "Rating" from 0 to 5 (float).

Assume we have already run import babypandas as bpd and import numpy as np.
If your answer is a string, put it in quotes. If your answer is a float, include a decimal point. No calculators and no computers were allowed.
Coleman purchased a property on Clougherty Drive, but the street number can only be determined by evaluating the following expression. What is the street number?
sum(2 ** np.arange(3, 7, 2)) * len(str(len("sushi" * 999)))Answer: 160
The average score on this problem was 48%.
After a few months of operation, Coleman notices that there are a few bugs in his restaurant data dashboard. For each expression below, help Coleman figure out what the expression will evaluate to, or write “error” if the expression produces an error.
menu.take(np.arange(3, 0, -1)).shape[1]Answer: 4
The average score on this problem was 46%.
np.array([10, menu.get("Type").loc["Tuna Sashimi"], 1.5])[2]Answer: "1.5"
The average score on this problem was 32%.
int(str(menu.get("Rating").max()))Answer: error
The average score on this problem was 56%.
Ella and Bianca, a duo of world renowned pizza-turned-sushi chefs, are interviewing jointly for a job at Coleman’s Catch. Help them ace their interview question by determining the output of the code block below. Write legibly!
food1 = "hamachi"
food2 = "sashimi"
food2.replace("sh", "iba").replace("s", "b") + "o".join(food1.split("a"))Answer: "baibaimihomochi"
The average score on this problem was 58%.
Ray, founder of Ray’s Reviews, writes that the sushi from Coleman’s Catch is delicious, but it may be overpriced. Fill in the blanks below to create a DataFrame called money, which is indexed by "Type" and has just one column, "price_per_piece", that contains the highest price per individual piece of a menu item in each of the different "Type" categories.
unit_price = menu.assign(price_per_piece = __(A)__)
money = unit_price.get(__(B)__).groupby("Type").__(C)__What goes in blank (A)?
Answer: menu.get("Price") / menu.get("Pieces")
The average score on this problem was 63%.
What goes in blank (B)?
Answer: ["Type", "price_per_piece"]
The average score on this problem was 38%.
What goes in blank (C)?
Answer: max()
The average score on this problem was 72%.
Coleman has trouble selling certain menu items, so he creates the Coleman’s Catch of the Day Combo. All menu items with ratings below 4.5 are considered clunkers. The combo consists of the most expensive clunker of each "Type", which he sells as a bundle for $30.
Fill in the blank so that clunkers is a DataFrame consisting of the rows of menu with ratings below 4.5.
clunkers = ____Answer: menu[menu.get("Rating") < 4.5]
The average score on this problem was 63%.
Which of the following evaluates to the amount of money a customer saves by purchasing the combo versus purchasing each item individually?
clunkers.groupby("Type").sum().get("Price").max() - 30
30 - clunkers.groupby("Type").sum().get("Price").max()
clunkers.groupby("Type").max().get("Price").sum() - 30
30 - clunkers.groupby("Type").max().get("Price").sum()
Answer: Option 3.
The average score on this problem was 51%.