Q17Comprehension5 Marks11 Dec 2022
Passage
Based on the above data, answer the given subquestions.
nums is a list of integers in which each element lies in the range 1 to 10, endpoints inclusive. A sample list of size 20 could look like this:
L = [2, 1, 3, 5, 1, 4, 9, 5, 9, 4, 1, 3, 5, 6, 4, 7, 10, 1, 7, 5]
The actual list nums has size n.
Let us continue with the list nums. The list is said to feature a streak if the number 5 occurs at least five times in a row. streak is a function which accepts the list nums as argument and returns True if it has a streak, and False otherwise. Select the correct implementation of this function.
sample test cases:
nums = [1, 2, 5, 5, 5, 5, 5, 1, 2, 10] -> True
nums = [4, 5, 2, 5, 5, 5, 5, 2, 5] -> False
nums = [10, 5, 5, 5, 5, 5, 1, 6, 7, 8, 9] -> True