Built-ins & Standard Library · Question 7 · Easy
enumerate is given start=1 while looping over two names. What does the loop print?
for i, name in enumerate(["Asha", "Ravi"], start=1):
print(i, name)
- 1 Asha 2 Ravi
- 0 Asha 1 Ravi
- 1 Asha 1 Ravi
- Asha 1 Ravi 2
Answer and explanation
Answer: A. 1 Asha 2 Ravi
Explanation: enumerate pairs each item with a running count, index first and item second. start=1 makes the count begin at 1 instead of the default 0.
Previous: math.floor is applied to a negative number and math.ceil to a positive one… · Next: A Counter is built from a list of drink orders and is then asked about a drink…
Practise built-ins & standard library
Try a fresh set of built-ins & standard library questions with an explanation after every answer, free and without signing up: Built-ins & Standard Library practice. Or sit a full placement mock test.
More built-ins & standard library questions
- A program starts with the line import math as m. Which call correctly computes…
- isinstance is given a tuple of types in one call and a single type in the…
- math.floor is applied to a negative number and math.ceil to a positive one…
- A Counter is built from a list of drink orders and is then asked about a drink…
- Words are grouped by their first letter using defaultdict(list). What does the…
- A deque gets an appendleft, a pop and a rotate(1). What does it hold at the end?
- max is called on a dictionary of city temperatures, once plainly and once with…
- zip is used with the * operator to split a list of pairs. What does this code…
- A file tools.py ends with a block under if __name__ == "__main__":. When does…
- itertools is used to count the 2-item combinations and the 2-item permutations…
More python practice
Variables, Types & Operators · Python Strings · Lists & Tuples · Dictionaries & Sets · Conditions & Loops · Functions & Scope · Comprehensions & Generators · Classes & Objects
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge