Bird
0
0

Which of these is a correct way to indent a Python if statement?

easy📝 Conceptual Q2 of 15
Python - Basics and Execution Environment
Which of these is a correct way to indent a Python if statement?
Aif x > 0: print('Positive')
Bif x > 0: print('Positive') print('Done')
Cif x > 0: print('Positive') print('Done')
Dif x > 0: print('Positive')
Step-by-Step Solution
Solution:
  1. Step 1: Check indentation after if statement

    Python requires the code inside the if block to be indented consistently, usually 4 spaces.
  2. Step 2: Identify correct indentation

    if x > 0: print('Positive') shows the print statement indented properly under the if condition.
  3. Final Answer:

    if x > 0:\n print('Positive') -> Option D
  4. Quick Check:

    Correct indentation = 4 spaces after colon [OK]
Quick Trick: Indent code inside blocks by 4 spaces [OK]
Common Mistakes:
MISTAKES
  • Not indenting code after colon
  • Mixing indentation levels in the same block
  • Indenting unrelated lines

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes