Checkpoint: Python Essentials
Reviewed & published by Brayan K
You've learned string formatting, string methods, sets, tuples, comprehensions, *args/**kwargs, lambda, enumerate and zip — let's combine them. This checkpoint isn't a new topic; it's where the separate pieces click into a single, working program.
Part of the free Python course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.
We'll recap each tool, build one realistic report together step by step, then run a short quiz to spot anything worth a second look.
What You've Learned
A quick map of the eight tools you're about to combine:
★ The Build Challenge: A Student Scoreboard
Here's the brief. You're given a list of (name, score) tuples. Build a small program that produces a ranked, formatted scoreboard and a short summary — using as many of this section's tools as naturally fit.
- Start from students = [("Ada", 88), ("Ben", 72), ...] (a list of tuples)
- Use a comprehension to keep only students who passed (score ≥ 60)
- Sort the passers by score, highest first, with a lambda key
- Loop with enumerate (start=1), unpack each tuple, and print an f-string report line
- Print a summary: pass count, the set of unique grade bands, and the top scorer
# === CHECKPOINT BUILD: Student Scoreboard ===
# A list of (name, score) tuples
students = [
("Ada", 88),
("Ben", 54),
("Cleo", 95),
("Dan", 72),
("Eve", 41),
("Finn", 80),
]
PASS_MARK = 60
# TODO 1: comprehension — keep only students who passed (score >= PASS_MARK)
passers = [] # replace with a comprehension
# TODO 2: sort passers by score, highest first, using a lambda key
ranked = passers # replace with sorted(..., key=lambda s: ..., reverse=True)
# TODO 3: helper that maps a score to a grade band (A/B/C)
def grade(score):
if score >= 90:
return "A"
elif score >= 75:
return "B"
return "C"
# TODO 4: print a numbered, formatted scoreboard with enumerate + f-strings
print("=== SCOREBOARD ===")
# for rank, (name, score) in enumerate(ranked, start=1):
# print(...)
# TODO 5: summary — pass count, unique grade bands (a set), top scorer
# bands = { ... for ... }
# print(...)💡 Worked Solution
Attempt the build first, then expand this to compare your approach. There's more than one correct answer — focus on whether each tool was used where it fits.
students = [
("Ada", 88), ("Ben", 54), ("Cleo", 95),
("Dan", 72), ("Eve", 41), ("Finn", 80),
]
PASS_MARK = 60
def grade(score):
if score >= 90:
return "A"
elif score >= 75:
return "B"
return "C"
# STEP 1 — comprehension to filter passers (keeps tuples)
passers = [(name, score) for name, score in students if score >= PASS_MARK]
# STEP 2 — sort by score, highest first, with a lambda key
ranked = sorted(passers, key=lambda s: s[1], reverse=True)
# STEP 4 — numbered, aligned scoreboard via enumerate + unpacking + f-strings
print("=== SCOREBOARD ===")
print(f"{'#':<3}{'Name':<8}{'Score':>6} Grade")
for rank, (name, score) in enumerate(ranked, start=1):
print(f"{rank:<3}{name:<8}{score:>6} {grade(score)}")
# STEP 5 — summary: count, unique grade bands (a set), and top scorer
bands = {grade(score) for name, score in ranked}
top_name, top_score = ranked[0] # tuple unpacking again
print("-" * 25)
print(f"Passed: {len(ranked)}/{len(students)}")
print(f"Grade bands awarded: {bands}")
print(f"Top scorer: {top_name} with {top_score}")=== SCOREBOARD ===
# Name Score Grade
1 Cleo 95 A
2 Ada 88 B
3 Finn 80 B
4 Dan 72 C
-------------------------
Passed: 4/6
Grade bands awarded: {'A', 'B', 'C'}
Top scorer: Cleo with 95Look at how many tools appear in those few lines: a comprehension filters, a lambda drives the sort, enumerate numbers the rows, tuple unpacking reads each record, an f-string with alignment formats every line, and a set comprehension collects the unique grade bands. This is the everyday shape of real Python data code.
+ Stretch Goal: A Flexible Reporter (uses *args / zip / dict)
Want to push further? This optional extension folds in *args, zip, and a dict comprehension. Read it, then try modifying it:
# Stretch: combine names + scores from parallel lists and average any subjects
def average(*scores):
return round(sum(scores) / len(scores), 1) if scores else 0
names = ["Ada", "Ben", "Cleo"]
maths = [88, 54, 95]
science = [92, 61, 89]
# zip three lists together, build a {name: avg} dict with a comprehension
report = {
name: average(m, s)
for name, m, s in zip(names, maths, science)
}
for name, avg in report.items():
print(f"{name:<6} avg {avg}")
# Who tops the class? max() with a lambda over the dict items
best = max(report.items(), key=lambda item: item[1])
print(f"\nTop average: {best[0]} ({best[1]})")
# ✅ Expected output:
# Ada avg 90.0
# Ben avg 57.5
# Cleo avg 92.0
#
# Top average: Cleo (92.0)📝 Checkpoint Quiz
Predict each answer, then reveal it. Each one maps back to a specific lesson if you want to review.
Total: $7.00 — the :.2f spec formats the integer as a float with two decimal places. (See: f-strings.)
2. What is the result?
print(" Hi-There ".strip().lower().replace("-", " "))hi there — the chain trims spaces, lowercases, then swaps the hyphen for a space. (See: String methods.)
3. What does this print?
a = {1, 2, 3}
b = {3, 4, 5}
print(a & b){3} — the & operator returns the intersection, the only element in both sets. (See: Sets.)
4. What is the output?
pair = (10, 20)
x, y = pair
print(x + y)30 — tuple unpacking sets x = 10 and y = 20, so their sum is 30. (See: Tuples.)
5. What does this build?
print([n for n in range(6) if n % 2 == 0])[0, 2, 4] — the comprehension keeps only the even numbers from 0–5. (See: Comprehensions.)
names = ["Ada", "Ben"]
for i, n in enumerate(names, start=1):
print(i, n)1 Ada then 2 Ben — enumerate with start=1 numbers the items from 1. (See: enumerate & zip.)
Frequently Asked Questions
Checkpoint cleared — these tools are now yours!
You combined f-strings, string methods, sets, tuples, comprehensions, *args/**kwargs, lambda, and enumerate/zip into a single working program. That's exactly how professional Python is written — small, sharp tools composed together.
Practice quiz
What does f"Total: {7:.2f}" produce?
- Total: 7
- Total: 7.00
- Total: 7.0
- Total: {7:.2f}
Answer: Total: 7.00. The :.2f format spec renders the number as a float with exactly two decimal places, so 7 becomes 7.00.
What is the result of " Hi-There ".strip().lower()?
- "hi-there"
- "Hi-There"
- " hi-there "
- "hi there"
Answer: "hi-there". strip() removes the surrounding spaces and lower() lowercases the letters; the hyphen is left untouched.
Given a = {1, 2, 3} and b = {3, 4, 5}, what does a & b return?
- {1, 2, 3, 4, 5}
- {1, 2}
- {3}
- {4, 5}
Answer: {3}. The & operator is set intersection, returning only the elements present in both sets — here just 3.
After pair = (10, 20) and x, y = pair, what is x + y?
- (10, 20)
- 1020
- 30
- an error
Answer: 30. Tuple unpacking assigns x = 10 and y = 20, so x + y evaluates to 30.
What does [n for n in range(6) if n % 2 == 0] produce?
- [0, 2, 4]
- [1, 3, 5]
- [0, 1, 2, 3, 4, 5]
- [2, 4, 6]
Answer: [0, 2, 4]. The comprehension keeps only the even numbers from 0 through 5, giving [0, 2, 4].
In enumerate(["Ada", "Ben"], start=1), what index does "Ada" get?
- 0
- 1
- 2
- None
Answer: 1. The start=1 argument makes enumerate begin counting at 1, so the first item "Ada" gets index 1.
What does a *args parameter collect inside a function?
- Extra keyword arguments as a dict
- Extra positional arguments as a tuple
- Only the first positional argument
- A single list that must be passed explicitly
Answer: Extra positional arguments as a tuple. *args gathers any extra positional arguments into a tuple; **kwargs is the one that gathers keyword arguments into a dict.
Which call sorts pairs by their second element, highest first?
- sorted(pairs, key=lambda p: p[0])
- sorted(pairs, key=lambda p: p[1], reverse=True)
- sorted(pairs, reverse=True)
- sorted(pairs, key=p[1])
Answer: sorted(pairs, key=lambda p: p[1], reverse=True). A lambda key of p[1] sorts by the second element, and reverse=True makes it descending (highest first).
What does zip(["a", "b"], [1, 2]) let you iterate over?
- The pairs ("a", 1) and ("b", 2)
- The list ["a", "b", 1, 2]
- Only the first list
- A dictionary {"a": 1, "b": 2}
Answer: The pairs ("a", 1) and ("b", 2). zip walks the lists in parallel, yielding tuples that pair items by position: ("a", 1) then ("b", 2).
What kind of object does {grade(s) for n, s in students} create?
- A list
- A tuple
- A set
- A generator
Answer: A set. Curly braces with a single expression (no key:value) build a set comprehension, which keeps only unique values.
Continue this course
- Previous: enumerate & zip
- Next: Regular Expressions (re) — Search, match and replace text patterns with the re module
- Quick reference: Python cheat sheet
Frequently asked questions
What is this checkpoint for?
A checkpoint is a consolidation lesson. Instead of introducing a brand-new topic, it pulls together everything from the recent run of lessons — f-strings, string methods, sets, tuples, comprehensions, *args/**kwargs, lambda, enumerate and zip — into one realistic build so you can feel how the pieces fit together.
Should I be able to do the build challenge without looking?
Aim to attempt each step yourself first, then reveal the solution to compare. If a step stumps you, that's a signal to revisit the specific lesson it came from. Struggling a little before seeing the answer is exactly how the concepts move into long-term memory.
Which single feature combines the most of these ideas?
Processing a list of tuples is the great unifier: you loop with enumerate for numbering, unpack each tuple, filter or transform with a comprehension, sort with a lambda key, and format every line with an f-string. The build challenge below is deliberately designed around exactly this pattern.
What comes after this checkpoint?
Next you move into Regular Expressions (the re module) — a powerful mini-language for finding and extracting patterns in text. Everything you just consolidated about strings and looping is the perfect foundation for it.
I got some quiz answers wrong — is that a problem?
Not at all. The quiz is a diagnostic, not a grade. Each wrong answer points you to one specific lesson to skim again. A few misses now save you from confusion later, so treat them as a free study plan rather than a failure.