
Monty Python Test
1) What is the meaning of life?
2) Write me an iterator that produces the powers of -2 for a given count.
Two points for an iterator. One point for a generator.
deadparrot(0) -> []
deadparrot(1) -> [0]
deadparrot(2) -> [1, -2]
deadparrot(3) -> [1, -2, 4]
deadparrot(7) -> [1, -2, 4,-8,16,-32,64]
3) List two advantages and two disadvantages of having dynamic typing.
ADV:____________________________________________________
ADV: ____________________________________________________
DIS: _____________________________________________________
DIS:______________________________________________________
4) Write me a list comprehension that produces the powers of -2 from -20 to -210.
5) Finish this code:
for line in open("/usr/share/dict/words",encoding='latin1').readlines():
for word in line.split():
if
print(word) # only prints words that start with a 'a' and end in a 'z'
6) What is the biggest difference between a list and a set?