Lab 2: Knowledge Check

Try to answer these questions on your own, to test your knowledge after working through the lab. Then click the button at the bottom to show the answers and check whether you were right or not. If you get a question wrong and don't understand why, that's a good sign that you should study that topic before the next quiz.

  1. The *type* of the value that results from the input function depends on what the user types when the program is run.
    True False
  2. In Python, one line of code can be more than one step of the program.
    True False
  3. If a zero-parameter function named 'greet' prints some text, how can you store that in a variable?
    1. greeting = greet()
    2. greeting = print(greet())
    3. greeting = print(greet)
    4. greet()
      greeting = print
    5. You cannot store printed text into a variable, unless you modify the function to store the text before it gets printed.
  4. Which of the following expressions evaluates to a number? (pick one or more)
    1. len('hello')
    2. int('hello')
    3. int('25')
    4. int(input('How are you feeling? '))
  5. Custom functions are useful because... (pick one or more)
    1. They allow you to easily repeat code multiple times without copying and pasting.
    2. They can help you divide up a larger problem into smaller problems that are easier to solve.
    3. It is impossible to define variables without function call frames.
    4. Function call frames help prevent accidental re-use of variables.

Table of Contents