Spring 2025 Quiz 2

← return to practice.dsc10.com


This quiz was administered in-person. It was closed-book; students were not allowed to use the DSC 10 Reference Sheet but were allowed a double-sided sheet of handwritten notes. Students had 20 minutes to work on the quiz.

This quiz covered Lectures 6-9 of the Spring 2025 offering of DSC 10.


The DataFrame ghibli contains information about all 25 films produced by Studio Ghibli, the acclaimed Japanese animation studio. For each film, we have its "Name", "Director", "Budget" and "Revenue" (both in millions of dollars), primary "Genre", and "Runtime" in minutes. ghibli has 25 rows. The first two are shown below.


Problem 1

Fill in the blanks below to add a new column to ghibli called "TimeString", containing the runtime of each film as a string in hours and minutes. For example, Spirited Away is 125 minutes long, so its value in the "TimeString" column would be "2 hours, 5 minutes".

def change_time(mins):
    hours = ___(a)___
    minutes = ___(b)___
    return str(hours) + " hours, " + str(minutes) + " minutes"
    
ghibli = ghibli.assign(TimeString = ___(c)___)

Answer (a): int(mins / 60)


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 73%.

Answer (b): mins % 60


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 62%.

Answer (c): ghibli.get("Runtime").apply(change_time)


Difficulty: ⭐️⭐️

The average score on this problem was 85%.


Problem 2

Below is a density histogram showing the distribution of "Runtime", in minutes, for all 25 films in ghibli.


Problem 2.1

How many Studio Ghibli films are at least 90 minutes long?

Answer: 19


Difficulty: ⭐️⭐️

The average score on this problem was 79%.


Problem 2.2

Imagine we changed our histogram to have just one bin, from 70 to 140 minutes. What would the height of this bin be? Give your answer as an exact fraction or decimal.

Answer: \frac{1}{70}


Difficulty: ⭐️⭐️⭐️

The average score on this problem was 58%.



Problem 3

Using ghibli, write one line of code that outputs a DataFrame describing how many films of each genre each director has directed.

Answer: ghibli.groupby(["Director", "Genre"]).count()


Difficulty: ⭐️⭐️

The average score on this problem was 86%.


Problem 4

Kate loves Studio Ghibli and she has been recording her viewings of their films in the kate DataFrame, which is shown in full below. Note that kate has repeated rows since Kate watched some films twice.

In ghibli, there are 11 films directed by Hayao Miyazaki and only 2 directed by Hiromasa Yonebayashi.

How many rows are in the DataFrame resulting from ghibli.merge(kate, on="Director")?

Answer: 81


Difficulty: ⭐️⭐️⭐️⭐️

The average score on this problem was 46%.


Problem 5

The scatter plot below shows the budget and revenue (in millions of dollars) for each of the 6 distinct films in kate. Answer each question below, or write “not enough info" if you don’t have enough information to answer.


Problem 5.1

How many of these films had less than 200 million dollars in revenue?

Answer: 4


Difficulty: ⭐️

The average score on this problem was 98%.



Problem 5.2

How many of these films earned a revenue more than five times their budget?

Answer: 4


Difficulty: ⭐️⭐️

The average score on this problem was 85%.



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