Lab 3: Knowledge Check
These questions check your knowledge of concepts from this lab. Use the button at the bottom to show your answers once you've attempted them.
-
If a function does not have a return value, when you call that function
None
will be displayed to the user of your program when it returns.
True False -
If a function uses
print
, the output it produces will not be displayed to the user of your program when that function is called unless that function call is itself inside of aprint
True False -
Which of the following will print the result value of the
custom
function? (pick one or more)
-
result = custom() print(result)
-
custom() print(custom)
-
custom() = result print(result)
-
print(custom())
-
-
Which of the following will store the result value of the
custom
function in a variable namedresult
?
-
result = custom
-
result = custom()
-
custom() result = custom
-
result = print(custom())
-
custom() = result
-
-
If we run the following code, what is printed?
x = 3 def f(x): print(x) def g(x): x = x + 1 f(0) g(17)
- Nothing is printed.
-
0
-
3
-
4
-
17
-
18
-
(bonus turtle question) Which of the following pieces of
turtle
code leave the turtle exactly where it started? (pick one or more)
-
forward(10) left(20) backward(10) right(20)
-
forward(10) left(20) right(20) backward(10)
-
left(20) forward(10) right(20) backward(10)
-
left(20) forward(10) backward(10) right(20)
-
forward(10) goto(0, 0)
-
-
(bonus hard-mode) In the following code, how many different variables named 'x' are there?
(pick one or more)x = 1 def a(x): print(x) def b(x): return x + 1 a(b(b(b(x))))
- 1
- 2
- 3
- 4
- 5