Lab 6: 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.
True or false: If you store a list in a variable, and then modify that list using a method like
.insert, when you access the list using the variable again, the value will be changed.
What does the
.appendmethod of lists return?
- Nothing: it just modifies the list you applied it to.
- The value that you appended to the list.
- The list that you appended to.
Which of the following statements are true about for vs. while loops? (pick one or more)
- For loops are more general than while loops.
- While loops are more general than for loops.
- Both for and while loops create loop variables.
- Both for and while loops have continuation conditions.
- Unlike while loops, for loops always loop over a sequence.
- An index loop can be created using a while loop or a for loop.
If we run the following code, what is the sequence of numbers that gets printed (ignoring formatting)?
x = 0 while x < 7: x += 2 print(x) x += 2 print(x) x += 2 print(x)
- 2, 4, 6
- 2, 4, 6, 8
- 2, 4, 8
- 2, 4, 8, 10
- 2, 4, 8, 10, 12
- 2, 4, 8, 10, 14, 16, 18
Table of Contents
- Lab 6 Home
- Part 0: Warm up/Mini-review
- Part 1: For Loops & Lists
- Part 2: Strings and loops
- Part 3: Loops and graphics
- Extra: Using the Debugger
- Knowledge Check