Session 13 Preparation — Videos, Reading and Quizzes
Do this Quiz on Session 13
as you watch the videos and read the textbook.
Print it and complete it using pencil or pen, or fill it in electronically — your choice.
- Here is the quiz in Microsoft Word in case you want to fill it in electronically in that format.
- List Operations
- Textbook reading: Section 6.4 —
Using Lists with Functions (pages 297-303).
Executive Summary: We have said in class and illustrated in the exercises and quizzes that
if an execution of the body of a function changes the value of one of its parameters, this will never change
the value of the corresponding argument from the calling function, because parameters are part of the local
namespace of the function. This is true if the parameter is a list, but there is a "catch."
If we assign a list as the value of a variable v, what v actually contains is a reference to
that list. So when we pass v as an argument to a function, the initial value of the corresponding parameter p in the
function is the same reference. If the function body assigns a different value to
p the reference v is unaffected. However, if the function changes p[i],
then v[i] is part of the same list object, so it also changes. The same is true of any
kind of changes to the list object. This section
explains all of this in detail with enlightening diagrams
and examples.
- Also focus your attention on:
- Call-by-value and call-by-reference (page
300).
- Tuples (page 301).
- Functions wiht a variable number of
arguments (page 300-301)
- Tuple Assignmernts (page
302)
- Functions that return multiple values (pages
302-303)
- Textbook reading: Section 6.5 —
Adapting Algorithms (pages 303-309).
This is another example of the kind of things we did with
the "connect the dots" program in the Session 11 class.
It involves taking a slightly larger problem than we have
been doing, breaking it into pieces, writing functions for
some of the pieces, and assembling them into a working
program. Read this section very carefully.
- Textbook reading: Section 6.6 —
Discovering Algorithms by Manipulating Physical Objects (pages
310-313).
In the Session 11 class, we mentioned the value of having
pencil and paper handy when designing and testing code.
THIs section suggests another helpful tool, using physical
objects to model what your program is supposed to do.
- Textbook reading: Chapter 6
summary (pages 325-326). A good
summary of the contents of this very important chapter.
We are skipping section 7 (two-dimensional lists) for now.