8.1.8 Citation
Question: 8.1 What will the following code display?
numbers = [1, 2, 3, 4, 5]
numbers[2] = 99
print(numbers)
Answer: [1, 2, 99, 4, 5]
Question: 8.2 What will the following code display?
numbers = list(range(3))
print(numbers)
Answer: [0, 1, 2]
Question: 8.3 What will the following code display?
numbers = [10] * 5
print(numbers)
Answer: [10, 10, 10, 10, 10]
Question: 8.4 What will the following code display?
numbers = list(range(1, 10, 2))
for n in numbers:
print(n)
Answer: 1
3
5
7
9
Question: 8.5 What will the following code display?
numbers = [1, 2, 3, 4, 5]
print(numbers[-2])
Answer: 4