Chapter 3 Quiz — Python and pandas for Cricket
Twenty questions. Answer each before opening the answer. All numbers come from the book's data snapshot (Cricsheet, through November 2026).
Multiple Choice
1. last_over = [0, 0, 6, 4, 6, 6]. What does last_over[2:4] return?
- (a)
[0, 6] - (b)
[6, 4] - (c)
[6, 4, 6] - (d)
[0, 6, 4]
Answer
(b) [6, 4]. A slice includes the start position (2, the third ball) and stops before the end position (4), so it returns positions 2 and 3.
2. Which Python type is strike_rate after strike_rate = 100 * 43 / 35?
- (a)
int - (b)
str - (c)
float - (d)
list
Answer
(c) float. Division with / always produces a float in Python 3, here 122.857…
3. In the book's definition, which deliveries count as balls faced by a batter?
- (a) All deliveries with the batter on strike
- (b) Legal deliveries only (no wides, no no-balls)
- (c) Deliveries on strike excluding wides (no-balls count)
- (d) Deliveries on which the batter scored
Answer
(c). A wide cannot be hit, so it is not a ball faced; a no-ball can be hit (and often is, especially on a free hit), so it counts.
4. You want IPL deliveries from the death overs of the 2026 season. Which line is correct?
- (a)
balls[balls["phase"] == "death" and balls["season"] == "2026"] - (b)
balls[(balls["phase"] == "death") & (balls["season"] == 2026)] - (c)
balls[(balls["phase"] == "death") & (balls["season"] == "2026")] - (d)
balls[balls["phase"] == "death" & balls["season"] == "2026"]
Answer
(c). (a) uses Python's and, which raises a ValueError on Series. (b) compares the text season column to the number 2026 and silently returns nothing. (d) lacks brackets, so & is evaluated before == and raises a TypeError.
5. What does balls.groupby("batter")["runs_batter"].sum() return?
- (a) A single number: total runs off the bat
- (b) A Series of total runs off the bat, one value per batter
- (c) A DataFrame with one row per delivery
- (d) A list of batter names
Answer
(b). Split by batter, sum each group's runs_batter, combine into a Series indexed by batter name.
6. In the 2026 IPL, which phase had the highest share of dot balls among legal balls?
- (a) Powerplay
- (b) Middle overs
- (c) Death overs
- (d) All three were equal
Answer
(a) Powerplay, at 41.4% (middle 28.4%, death 29.1%) — even though it also had the highest boundary percentage (26.7%). Feast or famine.
7. Why does games[games["season"] == "2020"] return zero rows for the IPL?
- (a) The 2020 IPL was cancelled
- (b) The 2020 season is stored as
"2020/21" - (c)
seasonis a number, so it needs== 2020 - (d) The 2020 matches have missing dates
Answer
(b). Cricsheet labels that season "2020/21" (it was played September–November 2020). The robust fix is filtering on start_date.dt.year == 2020.
8. You merge 2,480 innings rows with the matches table using how="left" and get 2,480 rows. What does that tell you?
- (a) The merge failed
- (b) Every innings found at most one matching match row, and none were lost
- (c) Some matches were duplicated
- (d) The matches table has 2,480 rows
Answer
(b). A left merge keeps every left-hand row; an unchanged row count means no key was duplicated in the right-hand table. (It does not by itself prove every row found a match — check for missing values in the merged columns for that.)
9. Which IPL batter scored the most runs in the 2026 season in the data?
- (a) Shubman Gill
- (b) V Kohli
- (c) V Suryavanshi
- (d) B Sai Sudharsan
Answer
(c) V Suryavanshi, 776 runs off 327 balls (strike rate 237.31), ahead of Gill (732) and Sai Sudharsan (722).
10. What does 14.5 mean in a fall-of-wickets list?
- (a) 14.5 overs as a decimal, i.e. 14 overs and 3 balls
- (b) The 5th ball of the 15th over
- (c) The 14th ball of the 5th over
- (d) The 5th wicket at a score of 14
Answer
(b). Cricket's overs notation: 14 completed overs plus 5 balls. It is not a decimal.
11. Timing three methods of computing every IPL batter's strike rate, the chapter found groupby about how many times faster than iterrows on its run?
- (a) About 2 times
- (b) About 10 times
- (c) About 109 times
- (d) About 10,000 times
Answer
(c), 0.048 s against 5.211 s on that machine. (A lean zip loop was much closer, at 0.085 s — the real culprit is iterrows, which builds an object for every row.)
True or False (with a one-line justification)
12. runs_total and runs_batter are always equal on a legal delivery.
Answer
False. Byes and leg-byes are legal deliveries whose runs go into runs_total but not runs_batter (the fifth row of the chapter's first head() showed 0 off the bat but 2 in total).
13. In the IPL matches table, a missing winner always means the match was abandoned.
Answer
False. Of the 25 missing winners, 16 are ties (decided by super overs, recorded in eliminator) and 9 are no-results.
14. The average IPL first-innings total (matches with a winner, no D/L) rose from 157.5 in 2012 to 195.7 in 2026.
Answer
True. The chapter reproduced both numbers from raw deliveries with a groupby and a merge.
15. Including super-over deliveries changes Kohli's IPL career strike rate.
Answer
True, slightly — 134.86 with super overs against the standard 134.80 without. Small here, but it means your number no longer matches anyone else's.
16. In IPL 2026, more than three-quarters of 200+ first-innings totals were successfully defended.
Answer
False. Only 20 of 37 (54.1%) were defended in 2026, against 75.9% across 2008–2026.
Short Answer
17. Give one reason why the batting order had to be inferred when rebuilding the 2025 final's scorecard, and describe the inference in one sentence.
Answer
Cricsheet does not store batting positions. We walked through the deliveries in order and recorded each batter the first time they appeared as striker or non-striker.
18. Explain why (p["runs_total"] == 0).mean() gives the dot-ball percentage (as a fraction).
Answer
The comparison produces a True/False Series; Python treats True as 1 and False as 0, so the mean is the number of Trues divided by the number of rows — the share of balls with zero runs.
19. The pivot table of 2026 phase strike rates shows Suryavanshi at 290.0 in the death overs. What should be printed next to that number, and why?
Answer
The balls faced behind it — 10. A strike rate from 10 balls describes one or two overs; it is far too small a sample to describe his ability in the death. Every rate needs its sample beside it.
Applied Scenario
20. A journalist sends you this code and says "Bumrah conceded nothing in 2026 — the column is empty":
jb = balls[(balls["bowler"] == "JJ Bumrah") & (balls["season"] == 2026)]
print(jb["runs_total"].sum()) # prints 0
(a) What is wrong? (b) Fix it. (c) What did Bumrah's 2026 IPL season actually look like in the data, and what would you caution the journalist about before they write about it?
Answer
(a) season is text, so comparing it with the number 2026 matches no rows; the sum of an empty column is 0. No error is raised. (b) balls[(balls["bowler"] == "JJ Bumrah") & (balls["season"] == "2026")], then bowling_summary(jb) to apply the standard definitions (runs conceded exclude byes and leg-byes). (c) 294 legal balls, 410 runs conceded, 4 wickets, economy 8.37 — against 6.48 (2024) and 6.68 (2025). Caution: 294 balls is about 49 overs, one season; the data shows what happened, not why (role, conditions, fitness, opponents or plain variance), and the book never speculates about players' private circumstances.
Scoring Guide
| Score | What it means |
|---|---|
| 18–20 | You are ready for Chapter 4. Skim the pitfalls once more and move on. |
| 14–17 | Solid. Re-run 03_groupby_pivot.py and 04_merge_missing_dates.py, changing the season or competition, until the patterns are automatic. |
| 10–13 | Re-read §3.5–3.7 and retype (don't copy) the filter, groupby and merge examples. |
| Below 10 | Start again at §3.1 with the scripts open, running each block as you read. Everything later in the book builds on this chapter. |