Week 2 Unit 2: Self-test

18. June 2024

Question 1

Which of the following statements about list indices are correct?

Note: There are 3 correct answers to this question.

Lists have negative indices.
The last element of a list always has the index "-0."
Individual elements of a list can be accessed using an index.
The index of a list element is always equal to the value of the element.
If a list contains 5 elements, the index of the last element has the value 4.

Question 2

What value does the variable x have after the following statements have been executed?

week2 unit2 f2

1
3
4
2

Question 3

What value does the variable x have after the following statements have been executed?

week2 unit2 f3

[1, 2, 3]
4
2
[4, 5, 6, 7]

< Previous unit | Next unit > | Course Overview