← 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 1-5 of the Spring 2025 offering
of DSC 10.
⚠️ PDF version available here .
In the video game Minecraft, players mine raw materials,
craft various tools, and build structures such as houses.
A player named Steve has several storage chests in which he keeps items
he owns. Each chest has a different descriptive name
and contains items of various types. For example, one of Steve’s chests
is called "Food" and it contains 12
"Golden Carrot" and 8 "Rabbit Stew" items.
The items DataFrame contains all the items Steve has in
his chests. It is indexed by "Item" (name of the item). The
columns are "Quantity" (number of such items) and
"Chest" (name of the chest where all such
items are stored). The first few rows are shown below, though
items has more rows than pictured.

Fill in the blanks so the expression below evaluates to the name of the chest that contains the most distinct items.
(items.groupby(___(a)___).___(b)___
.sort_values(by="Quantity", ascending=___(c)___).___(d)___)Answer:
"Chest"count()Falseindex[0]Solution:
We first use groupby("Chest") to group items that are
stored in the same chest. Next, we use .count() to count
the number of distinct items in each chest. Each row
now represents a single chest and the number of
distinct items within it. The "Quantity"
column contains the number of distinct items in each chest, while the
index contains the chest names. We then use
.sort_values(by="Quantity", ascending=False) to sort the
chests in descending order by their number of distinct
items. Because we sorted by descending order, the chest with the most
distinct items is the first row. This is why .index[0]
retrieves our desired answer. Sorting by ascending order and selecting
the last row (.index[-1]) would’ve worked as well.
The average score on this problem was 89%.
The average score on this problem was 39%.
The average score on this problem was 86%.
The average score on this problem was 67%.
Steve wants to build a village where each house is built using a
different "Item" from the
"Materials" chest (e.g., a cobblestone house, a wood house,
a brick house, etc). Assuming that each house requires at least 416
blocks of a single material, fill in the blanks so that the expression
below evaluates to the number of houses that Steve’s
village will have.
items[(___(a)___) & (___(b)___)].___(c)___Answer:
items.get("Chest") == "Materials"items.get("Quantity") >= 416shape[0]Solution:
We first use items.get("Chest") == "Materials" to
identify the rows corresponding to items stored in the
"Materials" chest. Next, we use
items.get("Quantity") >= 416 to identify items with at
least 416 blocks, since each house requires at least 416 blocks of a
single material. We combine these two conditions using
& to filter the DataFrame to only include items that
satisfy both conditions. Finally,
.shape[0] returns the number of rows in the filtered
DataFrame, giving us the total number of houses in Steve’s village. Note
that answer (a) and (b) may be swapped.
The average score on this problem was 71%.
The average score on this problem was 71%.
The average score on this problem was 27%.
Which of the following expressions evaluates to the number of
"Emerald"s in Steve’s chests? Select all that apply.
items.get("Quantity").loc["Emerald"]
(items[items.get("Item") == "Emerald"].sort_values(by="Quantity").loc["Emerald"])
items.sort_values(by="Quantity").get("Quantity").iloc[0]
items[items.index == "Emerald"].get("Quantity").iloc[0]
None of the above.
Answer:
Option 1 and Option 4
Solution:
Option 1 is correct because "Item" is
the index of our DataFrame, so .loc["Emerald"] retrieves
the quantity corresponding to the "Emerald" index label.
Option 2 is incorrect because "Item" is
the index, not a column. Therefore, items.get("Item") would
error. Option 3 is incorrect because sorting by
"Quantity" in ascending order and selecting
.iloc[0] retrieves the smallest quantity in the
DataFrame, which is not necessarily the quantity of Emeralds.
Option 4 is correct because
items.index == "Emerald" filters the DataFrame to the
singular row corresponding to Emeralds, and
.get("Quantity").iloc[0] retrieves the quantity from that
row.
The average score on this problem was 78%.
In early versions of Minecraft, players reported sighting a hazy figure with glowing eyes, who they nicknamed Herobrine. Examine the mysterious code that Herobrine left behind and determine the output. Write your answer exactly how the output would appear in Python. Do it wrong and your diamonds will disappear.
curse = 3 + 4 * 2 ** 2 - 6/3
curseAnswer: 17.0
Solution
Following the order of operations in Python, we start with
2 ** 2, which gives us 4. Our expression is
now 3 + 4 * 4 - 6/3. We can now focus on multiplication and
division. 4 * 4 is 16, and 6/3 is
2. Our expression is now 3 + 16 - 2. Working
from right to left, we get our final answer of 17.
The average score on this problem was 85%.
Below is the opening line from the legendary Minecraft parody song
Revenge:
line = "Creeper aww man"You want to create an echo effect to produce the following string:
"Creeper Creeper Creeper aww man"Which of the following code snippets produces this output? Select all that apply.
words = line.split(" ")
(words[0] + " ") * 3 + words[1] + " " + words[2]
line * 3
line.replace("Creeper", "Creeper Creeper Creeper")
words = line.split(" ")
" ".join(words[0] * 3 + words[1])
None of the above.
Answer:
Option 1 and Option 3
Solution:
Option 1 is correct because
line.split(" ") separates the string into individual words,
and (words[0] + " ") * 3 repeats "Creeper "
three times before concatenating the remaining words. Option
2 is incorrect because line * 3 repeats
concatenation of the entire string three times, producing
"Creeper aww manCreeper aww manCreeper aww man".
Option 3 is correct because
.replace("Creeper", "Creeper Creeper Creeper") replaces the
original occurrence of "Creeper" with three repetitions,
which is what we want. Option 4 is incorrect because
words[0] * 3 + words[1] creates
"CreeperCreeperCreeperaww", and " ".join(...)
inserts spaces between each character, producing
"C r e e p e r C r e e p e r C r e e p e r a w w".
The average score on this problem was 93%.