Lab, Dictionaries and Sets
7 tasks, easy to hard: Predict, then run, Write it, Complete it, Fix it, Trace it, Refactor it, Mini challenge. Hints come one at a time and you can see each answer. Lab work is saved as practice and earns no XP.
Open the lessonYou can read every task below. Running, checking and saving them needs a free ID.
7 tasks
Task 01 .Type what the program will print, then run it to compare.
Type exactly what this program prints.
Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and save your practice. Practice does not award XP.
Task 02 .Solve it from the prompt, starting from an empty editor.
Given the list people of dictionaries, print the name of everyone aged 18 or over, one per line: Ria then Tom.
Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and save your practice. Practice does not award XP.
Task 03 .Fill the marked gaps in the starter code.
Replace each ___ so the program builds a 3 by 2 grid of dots with separate rows, puts a # in row 0, column 1, and prints each row joined into a string.
Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and save your practice. Practice does not award XP.
Task 04 .The starter code has a bug. Repair it so the checks pass.
Task 05 .Fill the table with the variable values, step by step.
Each row shows r and grid each time either changes, once both exist.
grid = [[0, 0], [0, 0]]
for r in range(2):
grid[r][r] = r + 1Sign in or create a free ID to fill in and check this table.
Task 06 .Rewrite working code to the stated rule, keeping the same output. Rule: Loop over the list of records directly instead of over indexes.
This loop uses range(len(...)) and an index to reach each record. Rewrite it to loop over books directly. The output must not change.
Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and save your practice. Practice does not award XP.
Task 07 .A short task that combines this lesson with earlier ones.
classes maps each class name to a list of pupil records. For each class, print its average mark to one decimal place, then print the single best pupil across all classes:
5A: 77.5 5B: 88.0 Best: Dee (93)
Sign in to access the interactive Python editor, write and run code checks against automated tests, use hints, and save your practice. Practice does not award XP.