Write a Python snippet that turns a raw CSV record set into dictionaries and works out an aggregate — the shape of a typical data pipeline script.
Most data work in Python looks like this. You take some text from a source, you parse it with the csv module, and you turn each row into a dictionary that is keyed by the column names. The csv module is worth learning properly, because it handles quoted values, commas inside a field, and line breaks inside a field, none of which a plain split on commas can manage.
import csv
import io
raw = """team,member,points
red,Ada,12
blue,Grace,7
red,Linus,9
"""
totals = {}
for row in csv.DictReader(io.StringIO(raw)):
team = row['team']
points = int(row['points'])
if team not in totals:
totals[team] = 0
totals[team] = totals[team] + points
for team in sorted(totals):
print(team, totals[team])
The output shows a red total of 21 and a blue total of 7, printed in the order of the team names.
Look at the shape of the code, because it is the shape of most real pipelines. The rows arrive one at a time instead of being loaded into a list first. A plain dictionary does the counting, so the first time a team appears you add it with a value of zero. The totals are built while the rows arrive, rather than in a second pass over the data. For anything bigger than a small example, the same idea is written with pandas and its vectorised operations, or with DuckDB when you want to run SQL over Parquet files.
What an interviewer is really checking is whether you know two things. First, that the standard library is enough to build a prototype. Second, that you know when to move to a specialised library. Both halves of that answer matter.