Quiz for: Python `enumerate` for Looping with Counters
Question 1
Under the hood, what does the `enumerate` function return?
Question 2
What additional parameter can be passed to `enumerate` to start the count from a different number other than 0?
Question 3
Why is code with `enumerate` considered less error-prone?
Question 4
What will output be for the given code?
```python
seasons = ['Spring', 'Summer', 'Fall', 'Winter']
for count, season in enumerate(seasons, start=1):
print(count, season)
```
Question 5
What is a key advantage of using the `enumerate` function over a basic for loop with a counter?
Question 6
Which data structure mentioned in the notes is not suitable for looping with `range` and `len`?
Question 7
What is the primary purpose of the `enumerate` function in Python?
Question 8
Given the list `seasons = ['Spring', 'Summer', 'Fall', 'Winter']`, what will be the output using `enumerate` starting from 5?
Question 9
Which of the following is a correct use of the `enumerate` function?
Question 10
What will the output be for the following code?
```python
seasons = ['Spring', 'Summer', 'Fall', 'Winter']
count = 1
for season in seasons:
print(count, season)
count += 1
```
Question 11
Why might using `range` and `len` for indexing in loops be considered a drawback?
Question 12
How does using `enumerate` improve the readability of loop code?
Question 13
What is a potential drawback of using an external counter variable in loops?
Question 14
What will the following code output?
```python
seasons = ['Spring', 'Summer', 'Fall', 'Winter']
for i in range(len(seasons)):
print(i + 1, seasons[i])
```