Bird
0
0

Which of the following is the correct syntax to start a while loop in Python?

easy📝 Syntax Q12 of 15
Python - While Loop
Which of the following is the correct syntax to start a while loop in Python?
Awhile x > 0: print(x)
Bwhile x > 0 print(x):
Cwhile (x > 0) print x
Dwhile x > 0 { print(x) }
Step-by-Step Solution
Solution:
  1. Step 1: Recall Python's while loop syntax

    Python requires a colon (:) after the condition and indentation for the loop body.
  2. Step 2: Check each option

    while x > 0: print(x) uses colon and correct indentation style (single line allowed). Others have syntax errors.
  3. Final Answer:

    while x > 0: print(x) -> Option A
  4. Quick Check:

    Colon after condition = correct syntax [OK]
Quick Trick: Remember colon (:) after condition in while loops [OK]
Common Mistakes:
MISTAKES
  • Missing colon after condition
  • Using braces {} like other languages
  • Incorrect print statement syntax

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes