Fall 2026 Quiz 2

← 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 6-9 of the Fall 2026 offering of DSC 10.


Sujal, Austin, and Rishika cleared their schedules on October 3rd, only to realize that San Diego had become an oven that day, with temperatures crossing 100°F.

The DataFrame oct3 contains information on 10 various San Diego locations on that date. It is indexed by "Location". Its columns are "Temp" (int), the high temperature for the day; "Elevation" (int), the elevation in feet; and "Coastal" (bool), whether the location is coastal.

The oct3 DataFrame with Location as the index and Temp, Elevation, and Coastal columns for all 10 San Diego locations.

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.


Problem 1

Lecture 8

Sujal wants to see whether locations at higher elevations are cooler. Assume that he has already defined a function called elevation_category, which takes in an integer elevation in feet and returns "low" when the elevation is at most 100, "medium" when it is greater than 100 and at most 400, and "high" otherwise.


Problem 1.1

Write one line of code to create a DataFrame oct3_cat, which contains every column in oct3, plus a new column named "Elevation_Category" with the appropriate categorical label, "low", "medium", or "high".

Answer:

oct3_cat = oct3.assign(Elevation_Category=oct3.get("Elevation").apply(elevation_category))

Difficulty: ⭐️⭐️

The average score on this problem was 81%.


Problem 1.2

Which bar chart is produced by the following code? Bar heights are labeled for your convenience.

(oct3_cat
 .drop(columns=["Coastal"])
 .take(2 * np.arange(3) + 1)
 .take(np.arange(2))
 .groupby("Elevation_Category")
 .mean()
 .plot(kind="bar", y="Temp"))
Four candidate bar charts labeled A through D. A and B plot temperature by numeric elevation; C and D plot temperature by elevation category.

Answer: D.


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 64%.



Problem 2

Lecture 9

For this question, assume oct3_cat was correctly created in Question 1.


Problem 2.1

Write one line of code that evaluates to a DataFrame containing the average temperature associated with each combination of values in the "Elevation_Category" and "Coastal" columns.

Answer:

oct3_cat.groupby(["Coastal", "Elevation_Category"]).mean().get(["Temp"])

Difficulty: ⭐️⭐️

The average score on this problem was 82%.


Problem 2.2

Determine the output of the code cell below.

legend = bpd.DataFrame().assign(
         Elevation_Category=["low", "medium", "high"],
         Color=["yellow", "orange", "red"])
oct3_cat.merge(legend, on="Elevation_Category").shape[0]

Answer: 10


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 70%.


Problem 2.3

Determine the output of the code cell below.

legend2 = bpd.DataFrame().assign(
         Elevation_Category=["low", "medium", "medium", "high"],
         Color=["yellow", "orange", "red", "maroon"])
oct3_cat.merge(legend2, on="Elevation_Category").shape[0]

Answer: 14


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 64%.



Problem 3

Lecture 7


Problem 3.1

Rishika makes a density histogram of the 10 values in the "Temp" column of oct3, shown above. She uses the argument bins = np.arange(90, 110, 5). What is the height of the tallest bar?

Answer: 0.08


Difficulty: ⭐️⭐️⭐️⭐️⭐️

The average score on this problem was 29%.


Problem 3.2

Rishika then obtains a larger DataFrame of 200 locations. A density histogram of temperatures from this larger DataFrame of 200 locations has bins and heights given below. Assume all locations’ temperatures fall between 80°F and 110°F, inclusive.

Bin Height of Bar
[80,90) 0.02
[90,95) 0.04
[95,100) 0.06
[100,110] X

What is the value of X?

Answer: 0.03


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 66%.


Problem 3.3

How many of the 200 locations have a "Temp" in [90,100)?

Answer: 100


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 61%.



👋 Feedback: Find an error? Still confused? Have a suggestion? Let us know here.