Robotics & Artificial Intelligence
Which of the following loop does not execute even once, if the condition is false in the beginning?
- infinite
- while
- for
- none
Python Control Flow
3 Likes
Answer
while
Reason — The while loop checks the condition before executing the loop body. If the condition is false at the very beginning, the control will not enter the loop block and hence the loop will not execute even once.
Answered By
1 Like
Related Questions
Which of the following statement is a fixed iterative loop?
- for
- while
- if
- if-else
How is the range() function typically used in a for loop?
- range(start, end)
- range(end)
- range(start, end, step)
- range(step)
Which of the following statements is most appropriate to illustrate the difference between a for loop and a while loop?
- A for loop is used for fixed iterations, while a while loop is used for conditional statements.
- A for loop is more concise than a while loop.
- There is no difference between for loop and while loop.
- They are not interchangeable.
Which of the following statement holds valid with Python for loop?
- initial value is an optional
- stop value is mandatory
- step value is an optional
- none