Winter 2025 Final Exam
← return to practice.dsc10.com
Instructor(s): Janine Tiefenbruck
This exam was administered in-person. Students were allowed one page of double-
sided handwritten notes. No calculators were allowed. Students had 3 hours to take
this exam.
Problem 1
Lecture 8
While browsing the library, Hermione stumbles upon an old book containing game logs
for all Quidditch matches played at Hogwarts in the 18th century. Quidditch is a sport
played between two houses. It features three types of balls:
Quaffle: Worth 10 points when used to score a goal.
Bludger: Does not contribute points. Instead, used to distract the other team.
Snitch: Worth 150 points when caught. This immediately ends the game.
A game log is a list of actions that occurred during a Quidditch match. Each element of
a game log is a two-letter string where the first letter represents the house that
performed the action ("G" for Gryffindor, , "H" for Hufflepuff, "R" for Ravenclaw, "S"
for Slytherin) and the second letter indicates the type of Quidditch ball used in the
action ("Q" for Quaffle, "B" for Bludger, "S" for Snitch). For example, "RQ" in a game
log represents Ravenclaw scoring with the Quaffle to earn 10 points.
Hermione writes a function, logwarts , to calculate the final score of a Quidditch match
based on the actions in the game log. The inputs are a game log (a list, as described
above) and the full names of the two houses competing. The output is a list of length 4
containing the names of the teams and their corresponding scores. Example behavior
is given below.
https://practice.dsc10.com/wi25-final/index.html 1/27
,12/5/25, 1:57 PM Winter 2025 Final Exam
>>> logwarts(["RQ", "GQ", "RB", "GS"], "Gryffindor", "Ravenclaw")
["Gryffindor", 160, "Ravenclaw", 10]
>>> logwarts(["HB", "HQ", "HQ", "SS"], "Hufflepuff", "Slytherin")
["Hufflepuff", 20, "Slytherin", 150]
Fill in the blanks in the logwarts function below. Note that some of your answers are
used in more than one place in the code.
def logwarts(game_log, team1, team2):
score1 = __(a)__
score2 = __(a)__
for action in game_log:
house = __(b)__
ball = __(c)__
if __(d)__:
__(e)__:
score1 = score1 + 10
__(f)__:
score1 = score1 + 150
else:
__(e)__:
score2 = score2 + 10
__(f)__:
score2 = score2 + 150
return [team1, score1, team2, score2]
Problem 1.1
What goes in blank (a)?
Click to view the solution.
Problem 1.2
https://practice.dsc10.com/wi25-final/index.html 2/27
, 12/5/25, 1:57 PM Winter 2025 Final Exam
What goes in blank (b)?
Click to view the solution.
Problem 1.3
What goes in blank (c)?
Click to view the solution.
Problem 1.4
What goes in blank (d)?
Click to view the solution.
Problem 1.5
What goes in blank (e)?
Click to view the solution.
Problem 1.6
What goes in blank (f)?
Click to view the solution.
Problem 2
Lecture 5, 14
The Death Eaters are a powerful group of dark wizards who oppose Harry Potter and
his allies. Each Death Eater receives a unique identification number based on their
https://practice.dsc10.com/wi25-final/index.html 3/27