← return to practice.dsc10.com
This quiz was administered in-person. Students were allowed 1
double-sided cheatsheet. Students had 20 minutes to
work on the quiz.
This quiz covered Lectures 1-5 of the Fall 2025 offering of
DSC 10.
⚠️ PDF version available here .
You are the newest employee at Nintendo and you are tasked with creating the next Super Smash Brothers video game! Games in this famous series involve battles between characters from many different franchises, like Pokemon, Mario, and Legend of Zelda. You’ve been given the roster of characters (known as fighters) in the current game, but unfortunately, due to budget cuts, you’ll need to eliminate some of them.
The smash DataFrame, whose first few rows are shown
below, includes information on all fighters in the current game. For
each fighter, you have their "Name" (string),
"Species" (string), "Franchise" of origin
(string), "Year" of origin (int), and primary
"Weapon" (string).

Nintendo management sends you some information about your new job, but there seems to be an encryption puzzle blocking you from opening the file. To undo the encryption and open the file, determine the datatype of each expression below, or indicate that the expression produces an error.
smash.shape[0] / 1
int
float
str
bool
DataFrame
error
Answer: float
smash.shape[0] is the number of rows, which is an int. In Python, / always returns a float, even when the division comes out evenly, so n / 1 is a float like 60.0.
The average score on this problem was 64%.
str(len(smash)) * 2.0
int
float
str
bool
DataFrame
error
Answer: error
len(smash) returns the number of rows in the DataFrame, as an int. str(…) turns it into a string like “60”. You can multiply a string by an int to repeat it (“60” * 2 is “6060”), but not by a float. “60” * 2.0 raises a TypeError, even though 2.0 is a whole number.
The average score on this problem was 63%.
smash.get("Year").iloc[0] == "1981"
int
float
str
bool
DataFrame
error
Answer: bool
smash.get(“Year”) is a Series of ints, and .iloc[0] pulls out the first value, which is a single int. Comparing an int to the string “1981” doesn’t raise an error. == just returns False, because an int and a string are never equal. A comparison always gives a bool, so the type is bool. If the quiz had used < instead of ==, this would have been an error.
The average score on this problem was 71%.
smash.take([0])
int
float
str
bool
DataFrame
error
Answer: DataFrame
take returns a DataFrame with the rows at the given positions. Even though [0] selects only one row, the result is still a DataFrame (with one row), not a single value.
The average score on this problem was 75%.
For diversity, we need to cut fighters from the most common
"Species". Fill in the blanks below to find the
"Species" with the most fighters (i.e. the
"Species" most represented in smash).
smash.groupby("Species").___(a)___().sort_values(by="Year").___(b)___
(a): count
smash.groupby(“Species”).count() gives one row per species. Every other column holds the number of rows in that group, so the “Year” column now contains the number of fighters of each species. The column’s name is a leftover from the original data, but the values are counts.
(b): index[-1]
.sort_values(by=“Year”) sorts these counts from smallest to largest, so the species with the most fighters ends up in the last row. The species names are in the index, so index[-1] gives the name of the last row, which is the most common species.
If you wrote .index[0], you would get the species with the fewest fighters.
The average score on this problem was 64%.
You decide to eliminate some of the fighters that have
"Sword" as their "Weapon". Select
all expressions that evaluate to the total number of such
fighters.
smash[smash.get("Weapon") == "Sword"].shape[0]
smash.get("Weapon").count("Sword")
(smash.get("Weapon") == "Sword").shape[0]
smash[smash.get("Weapon") == "Sword"].sum()
smash.groupby("Weapon").count().get("Franchise").loc["Sword"]
None of the above.
Answer: Options 1 and 5.
Option 1: smash[smash.get(“Weapon”) == “Sword”].shape[0] The comparison makes a Boolean Series, and querying it using brackets keeps only the Sword rows. .shape[0] is the number of rows left, which is the number of sword fighters.
Option 5: smash.groupby(“Weapon”).count().get(“Franchise”).loc[“Sword”] Grouping by “Weapon” and counting gives the number of rows in each group in every column. Using the “Franchise” column, then looking up the “Sword” row with .loc, gives the number of sword fighters. Any other column would give the same number.
Options 2, 3, and 4 are wrong. Option 2: smash.get(“Weapon”).count(“Sword”) count on a Series doesn’t take an argument, so this raises an error. (String count does take an argument, but this is a Series, not a string.)
Option 3: (smash.get(“Weapon”) == “Sword”).shape[0] The Boolean Series has one entry for every fighter, True or False. Its shape[0] is the length of the whole Series, which is the total number of fighters. Nothing was filtered. To count the True values you would use .sum().
Option 4: smash[smash.get(“Weapon”) == “Sword”].sum() The filter is fine, but .sum() on a DataFrame adds up each column separately. It does not count rows, so it doesn’t give a single number of fighters.
The average score on this problem was 73%.
Alongside the unveiling of your new game, you’ll want to announce a
new fighter to build hype. The code below calculates the name of this
new fighter and stores it in the variable new. In the box,
write in the value of the new variable after the code
executes. Write clearly!
lu = "luigi"
dk = "dk"
new = "crash"
dk.replace("k", "kong")
new = ((lu + "t") * len(dk)).title()
new = new
Answer: "Luigitluigit"
dk.replace(“k”, “kong”) creates a new string, “dkong”, but the result is never assigned to anything. Strings can’t be changed in place, so dk is still “dk”.
len(dk) is 2, because dk is still “dk”.
lu + “t” is “luigit”.
“luigit” * 2 repeats it, giving “luigitluigit”.
.title() capitalizes the first letter of each word. There are no spaces, so the whole thing counts as one word and only the first letter changes, giving “Luigitluigit”.
new = new does nothing.
The average score on this problem was 44%.
For the opening trailer, your boss needs you to find out two facts about Super Smash Brothers history. Write one line of Python code that evaluates to each quantity below.
The median origin "Year" of all fighters in
smash.
Answer: smash.get("Year").median()
This gets the “Year” column as a Series, then call .median() on it.
The average score on this problem was 80%.
The name of the fighter with the earliest origin "Year"
(or in the case of a tie, any fighter from the earliest origin
"Year").
Answer:
smash.sort_values(by = "Year").get("Name").iloc[0] OR
smash.set_index("Name").sort_values(by = "Year").index[0]
Sort the table by “Year”, which goes from smallest to largest by default, so the earliest fighter ends up in the first row. Then grab the name at position 0.
In the first version, .get(“Name”) gets the Name column and .iloc[0] takes the first value. In the second version, set_index(“Name”) moves the names into the index, so .index[0] gives the first name after sorting.
You can’t use .loc[0] for this. Sorting rearranges the rows but keeps their original labels, so .loc[0] would find whichever fighter was originally in row 0, not the earliest one.
The average score on this problem was 63%.