Unit 1 - Practice Problems - Functions and Booleans
These problems are for practice. They are optional, but you are encouraged to complete them and discuss them with members of the course staff during lab and office hours.
0 - Function Calls
What is printed by the following program? (If there is an error, simply state that there is an error)
1 - Function Calls
What is printed by the following program? (If there is an error, simply state that there is an error)
2 - Function Calls
What is printed by the following program? (If there is an error, simply state that there is an error)
3 - Function Calls
What is printed by the following program? (If there is an error, simply state that there is an error)
4 - Functions and Scope
What is printed by the following program? (If there is an error, simply state that there is an error)
5 - Functions and Scope
What is printed by the following program? (If there is an error, simply state that there is an error)
6 - Functions and Scope
What is printed by the following program? (If there is an error, simply state that there is an error)
7 - Functions and Scope
What is printed by the following program? (If there is an error, simply state that there is an error)
8 - Functions and Scope
What is printed by the following program? (If there is an error, simply state that there is an error)
9 - Functions and Scope
What is printed by the following program? (If there is an error, simply state that there is an error)
10 - Functions and Scope
What is printed by the following program? (If there is an error, simply state that there is an error)
11 - Boolean Variables
What is printed by the following program? (If there is an error, simply state that there is an error)
12 - Boolean Variables
What is printed by the following program? (If there is an error, simply state that there is an error)
13 - Boolean Operations
Function sample_function(a,b)
can be replaced by a more simple expression. What is that expression?
14 - Boolean Operations
def substantial_function(a, b):
c = not (a or b)
d = (not a) and (not b)
if c or d:
return b
elif b:
return a
return c
Function substantial_function(a,b)
can be replaced by a more simple expression. What is that expression?
15 - Boolean Operations
def stoic_function(a, b):
return a
d = not (not a or b) and a == b
if b and not a:
c = a ^ b
elif d and not (a or b):
c = not b
else:
return a
return c == d
Function stoic_function(a,b)
can be replaced by a more simple expression. What is that expression?
16 - Gallery of Errors
Identify which of the following (if any) produce errors.
A
B
C
D
E
17 - Gallery of Errors
A
B
C
D
E