Summary
I recorded this session to give students a concise review of the Python concepts that have caused the most confusion on the recent quiz and to prepare them for the upcoming midterm and lab work. I start by defining the four basic programming patterns—index, counter, accumulator, and sentinel—so that students can recognise which pattern fits a given loop. I then walk through each quiz question, pointing out typical errors such as using the wrong boolean test, mixing up and/or, mis‑using range, and forgetting that print does not return a value. I stress that a proper function definition must include the def keyword, parentheses, a colon, and a return statement when a result is needed; otherwise the function only prints.
To improve code readability I advise against magic numbers and recommend assigning meaningful variables or using f‑strings for string interpolation. I remind the class that the midterm contributes 10 % to the final grade and note that most students scored above 80 %; I also confirm that the lab was completed within the allotted time and that undergraduate TAs will step in if additional help is required.
The second part of the lecture covers list manipulation. I demonstrate insert, pop, and append, then show how to sort a list of tuples. I explain that sorted expects a callable key, not the result of a function call, and that a lambda expression is the quickest way to supply an inline key—for example sorting by artist, stage, or popularity. I contrast the immutable sorted() which returns a new list with the mutable .sort() that rearranges the original, and I illustrate the use of reverse=True for descending order. Finally, I clarify memory handling: a shallow copy shares the same underlying objects, whereas a deep copy creates independent copies, which is essential when the data structure contains nested mutable objects.
Action items: replace magic numbers with named constants or f‑strings, write functions with explicit returns, choose sorted or .sort based on whether you need the original list unchanged, use lambda keys for ad‑hoc sorting, and apply deep copying when you must modify a copy without affecting the source. These practices will be applied in the next programming assignment and upcoming lab exercises.