Don't like this style? Click here to change it! blue.css
These daily challenges were a little bit beyond you (which is healthy).
For my annuity calculator I did a rough idea like this:
For the interactive Tic-Tac-Toe I borrowed the framework from Corey and added logic:
The basic idea I want to capture is that simple types (
are copied at assignment while complex (AKA non-atomic) types (
aliased at assignment. An example:
For aliased data:
That example had a new style of list creation in it. We'll talk about that some more in a minute. For now
.insert(0,0) impacted both variable names! This is because
is actually just an alias of
Non-Atomic Task 1: What happens in the next snippet?
Non-Atomic Task 2: What about this one?
Atomic Task 3: What is the value of
SimonesDad at the end of this
Local Task 4: Why doesn't the for loop change
SimonesDad in the
Interactive Local 5: Add a command to that
for loop which displays each
letter after it was upper-cased.
Football Task 6: Fix the following program:
Clone Task 7: What is happening in this alternate universe?
Clone List Task 8: Hand-clone this list:
first_4 = [1, 2, 3, 4].
5 to your clone. Print
Copy Module Task 9: There is an easy way. The Python
Observe the following snippet. Use
copy.copy to build me a team of 4 clones and work each clone for
Lost Name Task 10: What goes wrong in the next snippet?
Deep Copy 11: Use the
dir(copy) trick, along with
help(copy.deepcopy) to fix that situation. Describe to your neighbor the difference between a "copy"
and a "deep copy".
Double Check Task 12: I'm going to give you four functions. Tell me which ones made copies and which ones made aliases.
If there is still time let's go to last Wednesday's Notes and explore the
This is adapted from another section of 106's recent exam. How would you do? (Imagine it on paper.) For this daily challenge I want you to work this practice exam and I'll give answers Monday morning.