Complete the code to get a slice of the array from index 1 to 3.
let numbers = [10, 20, 30, 40, 50] let slice = numbers[[1]]
The slice 1...3 gets elements at indices 1, 2, and 3.
Complete the code to get the first three elements of the array using prefix.
let fruits = ["apple", "banana", "cherry", "date"] let firstThree = fruits.[1](3)
The prefix(3) method returns the first three elements of the collection.
Fix the error in the code to correctly get a slice from index 2 to the end.
let letters = ["a", "b", "c", "d", "e"] let slice = letters[[1]...]
Using 2... gets the slice from index 2 to the end.
Fill both blanks to create a slice of the array from index 1 up to but not including index 4.
let colors = ["red", "green", "blue", "yellow", "purple"] let slice = colors[[1]..<[2]]
The half-open range 1..<4 includes indices 1, 2, and 3.
Fill all three blanks to create a dictionary with keys as uppercase letters and values as their index, only for letters with index greater than 1.
let letters = ["a", "b", "c", "d", "e"] let dict = [[1]: [2] for (index, letter) in letters.enumerated() if index [3] 1]
This comprehension creates a dictionary where keys are uppercase letters and values are their indices, only for indices greater than 1.