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.
The *type* of the value that results from the input function depends on what the user types when the program is run.
In Python, one line of code can be more than one step of the program.
If a zero-parameter function named 'greet' prints some text, how can you store that in a variable?
- greeting = greet()
- greeting = print(greet())
- greeting = print(greet)
greeting = print
- You cannot store printed text into a variable, unless you modify the function to store the text before it gets printed.
Which of the following expressions evaluates to a number? (pick one or more)
- int(input('How are you feeling? '))
Custom functions are useful because... (pick one or more)
- They allow you to easily repeat code multiple times without copying and pasting.
- They can help you divide up a larger problem into smaller problems that are easier to solve.
- It is impossible to define variables without function call frames.
- Function call frames help prevent accidental re-use of variables.
Table of Contents
- Lab 2 Home
- Part 0: Warm up worksheet
- Part 1: Debugging in Thonny
- Part 2: Parameter Practice
- Part 3A: Turtles like Bagels
- Part 3B: Musical Motifs
- Knowledge Check