What is the key feature of the 'for' loop in Python?
A
It requires a condition to terminate
B
It is used exclusively for numerical iterations
C
It iterates over a sequence of elements
Correct answer
D
It can only be nested within a 'while' loop
Correct answer
C. It iterates over a sequence of elements
15 views
⚔️
Challenge a friend on Python
Same MCQs, timed, live leaderboard. Send the link on WhatsApp – no sign-up needed.
Create challenge
Explanation
The 'for' loop in Python is used to iterate over a sequence of elements such as lists, tuples, strings, or ranges. It iterates through each item in the sequence and executes the block of code for each item.
Doubts & discussionNot sure why the answer is C? Ask here and get an explanation.
Ask a doubt about this MCQ
‹ Previous MCQ Which of the following statements is used to execute a block of code repeatedly in Python? Next MCQ › Which statement is used to terminate the current loop iteration in Python?