# Winter 2024 Quiz 2

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.

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

• "Mfr" (str): the company that manufactures the laptop, like “Apple” or “Dell”.
• "Model" (str): the model name of the laptop, such as “MacBook Pro”.
• "OS" (str): the operating system, such as “macOS” or “Windows 11”.
• "Screen Size" (float): the diagonal length of the screen, in inches.
• "Price" (float): the price of the laptop, in dollars.

## Problem 1

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 (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

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

Select all the true statements below.

• When you set the index of a DataFrame, the specified column becomes the index, and the old index becomes a column.

• After grouping a DataFrame, the resulting number of rows is less than or equal to the original number of rows.

• The area of a density histogram is always equal to 1.

• A scatter plot has one numerical axis and one categorical axis.

• The height of the tallest bar in a density histogram is always less than 1.

Answer: Option 2 and Option 3

##### Difficulty: ⭐️⭐️

The average score on this problem was 84%.

## Problem 4

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.

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

The average score on this problem was 72%.

## Problem 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%.