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.

  1. 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
  2. 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 a print
    True False
  3. Which of the following will print the result value of the custom function? (pick one or more)
    1. result = custom()
      print(result)
    2. custom()
      print(custom)
    3. custom() = result
      print(result)
    4. print(custom())
  4. Which of the following will store the result value of the custom function in a variable named result?
    1. result = custom
    2. result = custom()
    3. custom()
      result = custom
    4. result = print(custom())
    5. custom() = result
  5. 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)

    1. Nothing is printed.
    2. 0
    3. 3
    4. 4
    5. 17
    6. 18
  6. (bonus turtle question) Which of the following pieces of turtle code leave the turtle exactly where it started? (pick one or more)
    1. forward(10)
      left(20)
      backward(10)
      right(20)
    2. forward(10)
      left(20)
      right(20)
      backward(10)
    3. left(20)
      forward(10)
      right(20)
      backward(10)
    4. left(20)
      forward(10)
      backward(10)
      right(20)
    5. forward(10)
      goto(0, 0)
  7. (bonus hard-mode) In the following code, how many different variables named 'x' are there?
    x = 1
    
    def a(x):
        print(x)
    
    def b(x):
        return x + 1
    
    a(b(b(b(x))))
    (pick one or more)
    1. 1
    2. 2
    3. 3
    4. 4
    5. 5

Table of Contents