Week 9 — Lists, Methods, and the Backup That Was Not — Traditional alternative (no AI)
Instructors: publish this instead of the adaptive version if you prefer, and unpublish or delete the adaptive one.
Assignment 8 of the term — read and change lists, predict what each list method hands back, tell an alias from a copy, and explain it all to someone who has never programmed.
This week you learned that a list keeps many values under one name, that its methods change it in place and most of them hand back None, that backup = setlist gives one list a second name, and that a loop must never remove items from the list it is walking. In this assignment you trace four short problems, run each one to check your prediction, run four more programs that show the biggest day, extend, a true copy, and a cure for the loop trap, and explain a real mix-up to someone who has never programmed. This builds on Week 7's functions and the None a function hands back. This week's lecture tutorial, quiz, discussion, and Coding Lab practise the same ideas from other angles.
The task
A friend who directs a community choir keeps the night's songs in a short program: setlist = ["intro", "anthem", "lullaby", "march", "waltz", "finale"]. Before cutting two songs, your friend wrote backup = setlist to keep the full list safe, then ran setlist.remove("march") and setlist.remove("waltz"). Later, your friend printed backup and found songs missing, and says, "My backup lost songs I never touched." Your job is to check what Python really did, the way a programmer would: predict each output before you run it, run it in a free browser Python runner, and explain what happened. All four problems are illustrative; Problem 1 uses this week's reading log, whose daily list is [12, 40, 25, 0, 33, 17, 27].
Work these four problems. For each one, write your prediction first, then run the code and write the actual output beside your prediction:
- The reading log's daily list holds 7 days whose pages total 154. What does
print(total / len(daily))show? - A list starts as
a = [1, 2], and thena.append([3, 4])runs. How many items doeslen(a)report? - Your friend's setlist holds 6 songs,
backup = setlistruns, and then twosetlist.removecalls delete 2 songs. How many songs doeslen(backup)report? - A loop walks
minutes = [0, 0, 90, 0, 85]and callsminutes.remove(0)for each 0 it sees. How many items doeslen(minutes)report afterward?
Beside each answer, add one brief interpretation:
- Problem 1: explain why the line shows a decimal point, and run the reading log's biggest-day loop to say what it prints and why it starts at
daily[0]. - Problem 2: explain why
appendadded only one item, then run the same program withextendinstead and report the length. - Problem 3: explain why the backup changed, then change
backup = setlisttobackup = setlist[:], run it, and report the length and whatbackup is setlistprints. - Problem 4: explain why one 0 survives the loop, then run one of this week's two cures and report what it prints.
Explain it to a non-programmer
Write a 3–5 sentence message to your friend that explains, in everyday words, why the backup lost two songs and how changing one line keeps the full list safe. Use the idea that backup = setlist gives one list a second name, and name one limit or caveat, such as the fact that a copy made before the cuts will not pick up songs added later. Explain any technical term in everyday words. More than one good message is possible.
For a different, ungraded example, imagine a roommate whose program sorted a grocery list with groceries = groceries.sort() and then printed None instead of the list. Model message: "The sort command does its work right on the list and then hands back nothing, which Python calls None. Your line stored that nothing back under the list's name, so the sorted list was lost. Writing the sort on its own line, without the equals sign, keeps the list and puts it in order. One catch: that changes the original order for good, so if you still need the old order, ask for a sorted copy instead."
Use that pattern for your friend's question, with your own wording and evidence.
Show your traces. A reader should be able to follow every prediction step by step and see the actual output of your run beside it, without guessing what a list held after each line or which names pointed at it.
Deliverables
Submit a single report containing:
- the four answers, each with your prediction, the step-by-step trace, the actual output of your run, and the brief interpretation the task names for that problem;
- the runs of the biggest-day loop, the
extendversion, the full-slice backup with itsistest, and one cure for the loop trap, each with what printed; and - your message to your friend, explaining why the backup lost two songs, how one changed line keeps the full list safe, and one limit.
Keep it to roughly one page. Clear and correct beats long.
Choose how you show it. Present your report as written text, or as a recorded audio or video explanation of about three minutes with a transcript, or as labelled screen captures of your runs with a short note for each. Every form is graded by the same scoring criteria. Submit in any accessible file type or as a link; a recorded response may be submitted as audio or video with a transcript, or as text.
How you'll be graded
The full analytic rubric is attached to this assignment in Canvas.
Academic integrity and AI use
This version is designed to be completed without AI: make the predictions, run the code, and write the interpretations and the message yourself, without any AI tool. You may use a free browser Python runner, Python Tutor, and the official Python documentation. Submitting AI-generated work as your own, or copying another student's work, is an integrity violation under the course policy.
Built with The Course Maker · samples.thecoursemaker.com