MCQ
Single Best Answer
Moderate
QWhich of the following allows looping over a collection in Python?
ID: #23077
For Loop in Programming Language
73 views
Question Info
#23077Q ID
ModerateDifficulty
For Loop in Programming LanguageTopic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer: Option B
Explanation
In Python, the for loop syntax uses the in keyword to iterate over an iterable such as a list, tuple, or range. The range(5) generates a sequence of numbers from 0 to 4, and the loop iterates through each number in that sequence. Option A and C are syntax used in languages like Java or C++, and Option D resembles the foreach loop from languages like PHP or C#, but it's not valid in Python.
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic