Recall & Review
beginner
What is array indexing?
Array indexing is the way to access a single element in an array using its position number, starting from zero.
Click to reveal answer
beginner
How do you slice an array in Python?
Slicing means taking a part of an array by specifying a start and end position like array[start:end]. It gives a new array with elements from start up to but not including end.
Click to reveal answer
intermediate
What does negative indexing do in arrays?
Negative indexing counts from the end of the array. For example, -1 means the last element, -2 means the second last, and so on.
Click to reveal answer
intermediate
Explain the slice notation array[start:end:step].
This notation lets you pick elements from start to end (not including end) by skipping elements according to step. For example, step=2 picks every second element.
Click to reveal answer
beginner
What happens if you omit start or end in slicing?
If start is omitted, slicing starts from the beginning. If end is omitted, slicing goes to the last element. For example, array[:3] means from start to index 2.
Click to reveal answer
What is the index of the first element in a Python array?
✗ Incorrect
Python arrays start counting at zero, so the first element is at index 0.
What does array[2:5] return?
✗ Incorrect
Slicing includes the start index but excludes the end index.
What does negative index -1 mean in an array?
✗ Incorrect
Negative indices count from the end, so -1 is the last element.
What will array[::2] do?
✗ Incorrect
The step of 2 means pick every second element starting at index 0.
If you want to slice from the start to index 4, which is correct?
✗ Incorrect
Slicing excludes the end index, so to include index 4, end should be 5.
Describe how to access the last three elements of an array using slicing.
Think about counting from the end with negative numbers.
You got /3 concepts.
Explain the difference between array indexing and slicing with examples.
Indexing gets one item, slicing gets a part of the array.
You got /3 concepts.