Good place to stop if you're short on time — step 3 picks up here.
Lesson idea Tap to fold
What does a comparison such as score >= 4 produce?
Show the answer
A Boolean value—True or False—for each value being compared.
A mask makes one decision for every row
A Series comparison returns a boolean Series with one decision per row. df[mask] selects its True rows; df.loc[mask] is another valid form. The result follows row order and index alignment, not an assumed zero-based position.
For two conditions, use & for elementwise AND and | for elementwise OR. Put parentheses around each comparison. Python and/or instead try to obtain one overall truth value from a Series and raise an ambiguous-truth error.
These examples assume numeric duration/score and boolean artifact facts, with missing numeric values excluded by the comparison. Exactly four qualifies for score >= 4; exactly eight qualifies for duration <= 8. The task is a classroom shortlist rule, not an authoritative delivery judgment.
# A mask makes one decision for every row.
import pandas as pd
df = pd.DataFrame([
{"item_id": "Museum", "score": 4, "artifact": False},
{"item_id": "Canal", "score": 5, "artifact": True},
])
mask = (df["score"] >= 4) & (df["artifact"] == False)
selected = df.loc[mask]
print(selected["item_id"].tolist())
Only ['Museum'] remains. Canal’s high score cannot overcome its artifact flag because both conditions are required.
Test the exact boundary and a row that meets only one condition. A familiar sample list is not proof that the mask works.
Predict, explain, then test
These three brief checks are self-reviewed, not scored. Answer before opening the comparison. Coding checks use unfamiliar tables under the stated task assumptions.
Trace the boundary
Does score exactly 4 satisfy score >= 4?
Compare your answer · self-reviewed
Yes. A strict > comparison would implement a different rule.
Choose an operator
Why is Python and wrong between two Series comparisons?
Compare your answer · self-reviewed
It asks for one truth value for the Series. Use elementwise & with parentheses.
Check order
Does filtering automatically sort the matching item IDs?
Compare your answer · self-reviewed
No. Filtering retains their current row order; sorting is a separate operation.
Choose an exercise to load its prompt.
Loading exercises…
Noted on your route map, with the step you were on. Nothing is lost by parking it — the next review day will bring this idea back, and the flag tells the course where to slow down.
The tutor mounts here when JavaScript is available. The lesson above stays readable without it.