The questions below assume that you have read Chapter 3 .
Be concise in your answers! Most questions can be answered in one sentence.
Q1: What is the singleton design pattern? How many objects does the expression [True, False, True, False]
generate in memory?
< your answer >
Q2: What do we mean when we talk about truthy and falsy expressions?
< your answer >
Q3: Describe in your own words the concept of short-circuiting! What does it imply for an individual sub-expression in a boolean expression?
< your answer >
Q4: Explain how the conceptual difference between a statement and an expression relates to the difference between a conditional statement and a conditional expression.
< your answer >
Q5: Why is the use of temporary variables encouraged in Python?
< your answer >
Q6: What does the finally
-clause enforce in this code snippet? How can a try
statement be useful without an except
-clause?
try:
print("Make a request to a service on the internet")
finally:
print("This could be clean-up code")
< your answer >
Motivate your answer with one short sentence!
Q7: The objects True
, False
, and None
represent the idea of yes, no, and maybe answers in a natural language.
Hint: you also respond with a code cell.
< your answer >
Q8: The try
statement is useful for handling syntax errors.
< your answer >