Python Programming - Loops
Exercise : Loops - General Questions
- Loops - General Questions
16.
How can you create an infinite loop?
Answer: Option
Explanation:
while True: creates an infinite loop, as the condition is always true.
17.
What is the purpose of the enumerate function when used with a for loop?
Answer: Option
Explanation:
The
enumerate function is used in a for loop to iterate over both the index and value of each element in a sequence.
18.
What is the purpose of the
reverse parameter in the range function?
Answer: Option
Explanation:
The
range function's reverse parameter is used to create a reversed range from a specified end to start.
19.
In Python, what does the
pass statement do when used in a loop?Answer: Option
Explanation:
The
pass statement does nothing and is used as a placeholder.
20.
Which function is used to find the minimum value from a sequence?
Answer: Option
Explanation:
The
min() function is used to find the minimum value from a sequence in Python.
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers