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
.append
or.insert
, when you access the list using the variable again, the value will be changed.
True False -
What does the
.append
method 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.
-
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