← 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.

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.

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"`

The average score on this problem was 92%.

**Answer (b):** `count()`

The average score on this problem was 82%.

**Answer (c):** `"Model"`

, `"OS"`

,
`"Screen Size"`

, or `"Price"`

The average score on this problem was 56%.

**Answer (d):** `count()`

The average score on this problem was 68%.

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"`

The average score on this problem was 71%.

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

The average score on this problem was 71%.

**Answer (c):** `&`

The average score on this problem was 43%.

**Answer (d):** `shape[0]`

The average score on this problem was 43%.

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

The average score on this problem was 84%.

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%

The average score on this problem was 72%.

**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"]`

The average score on this problem was 72%.

**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()`

The average score on this problem was 71%.