Question 1. see rep_chars.py.


-----

Question 2. The answer, according to the shell, is below.

>>> print 3 + 8.0
11.0
>>> print True and True or False
True
>>> x = 5
>>> x = x + x + 1 + x
# The next line is  NOT a print statement! Students did not have to give this
>>> x+3
19 
>>> print x
16
>>> print 'abc'.find('b') * 3
3
>>> x = [1, 2, 3]
>>> y = x[2]
>>> y += 1
>>> print x
[1, 2, 3]

-----

Question 3.

a. Pictures are mutable. When we modify the picture referenced by 'pic' we change what 'pic' refers to in the calling code.

the key idea is mutability. This has to be evident in the answer for full marks.

B. The int function converts a value of a different type to an integer. If we left it out, we might assign a non-integer value to a color component, which is illegal (color components are integers in the range 0-255).


-----

Question 4. See pw.py

Note that another popular way to solve this may be a raw_input above the loop to get the first password, and then another raw_input inside the loop to keep asking for a valid password. This is OK, since max_attempts is assumed to be at least 1.

