Winter 2024 Quiz 2

← return to practice.dsc10.com


This quiz was administered in-person. It was closed-book and closed-note; students were not allowed to use the DSC 10 Reference Sheet. Students had 20 minutes to work on the quiz.

This quiz covered Lectures 5-7 of the Winter 2024 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.


The laptops DataFrame contains information on various factors that influence the pricing of laptops. Each row represents a laptop, and the columns are:


Problem 1

Lecture 6

We’d like to visualize the distribution of the "Mfr" column in the laptops DataFrame. Fill in the blanks so that the code below draws an appropriate plot.

laptops.groupby(__(a)__).__(b)__.get([__(c)__]).plot(kind=__(d)__)

Answer:

Answer (a): "Mfr"


Difficulty: ⭐️

The average score on this problem was 92%.

Answer (b): count()


Difficulty: ⭐️⭐️

The average score on this problem was 82%.

Answer (c): "Model", "OS", "Screen Size", or "Price"


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 56%.

Answer (d): "bar" or "barh"


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 68%.


Problem 2

Lecture 5

Fill in the blanks so that rotten_apple evaluates to the number of laptops manufactured by "Apple" that are priced below the median price of all laptops.

x = __(a)__
y = __(b)__
rotten_apple = laptops[x __(c)__ y].__(d)__

Note: (a) and (b) are interchangeable

Answer (a): laptops.get("Mfr") == "Apple"


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 71%.

Answer (b): laptops.get("Price") < laptops.get("Price").median()


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 71%.

Answer (c): &


Difficulty: ⭐️⭐️⭐️⭐️

The average score on this problem was 43%.

Answer (d): shape[0]


Difficulty: ⭐️⭐️⭐️⭐️

The average score on this problem was 43%.


Problem 3

Lecture 7

Select all the true statements below.

Answer: Option 2 and Option 3


Difficulty: ⭐️⭐️

The average score on this problem was 84%.


Problem 4

Lecture 7

A density histogram of "Screen Size" is shown below.

What percentage of computer models have a "Screen Size" of at least 16 inches but less than 18 inches? Give your answer as an integer rounded to the nearest multiple of 5.

Answer 35%


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 72%.


Problem 5

Lecture 5


Problem 5.1

Using groupby, write an expression that evaluates to the average price of laptops with the "macOS" operating system.

Answer: laptops.groupby("OS").mean().get("Price").loc["macOS"]


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 72%.



Problem 5.2

Without using groupby, write an expression that evaluates to the average price of laptops with the "macOS" operating system (the same quantity as above).

Answer: laptops[laptops.get("OS") == "macOS"].get("Price").mean()


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 71%.



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