QUESTION IMAGE
Question
question: 9 what is the difference between a for loop and a while loop? a for loop repeats commands a specific number of times and a while loop repeats until a condition becomes false. a for loop is used to make decisions between two options and a while loop is used to make decisions between 3 options or more. a for loop is used when the variable is less than 10 and a while loop is used when the variable is 10 or greater. a for loop is used when we only need to meet one condition and a while loop is used when there are two or more conditions.
- Analyze each option:
- Option 1: A for loop typically iterates a specific number of times (e.g., for a fixed range), and a while loop continues as long as a condition is true (repeats until the condition becomes false). This matches the standard definitions of for and while loops in programming.
- Option 2: Loops (for/while) are for repetition, not decision - making between options (that's switch/case or if - else - if for multiple options). So this is incorrect.
- Option 3: The use of for and while loops has nothing to do with the value of a variable being less than 10 or 10 or greater. This is a wrong distinction.
- Option 4: Both for and while loops can handle one or multiple conditions. The number of conditions is not the defining factor for choosing between them. So this is incorrect.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
A. A for loop repeats commands a specific number of times and a while loop repeats until a condition becomes false.