nerdexam
Huawei

H13-311_V3.5 · Question #215

How many spaces does PEP 8 stipulate that Python's first fine indentation needs to indent?

The correct answer is C. 4. PEP 8, Python's official style guide, stipulates 4 spaces per indentation level as the standard for Python code, making C the correct answer. Option A (1 space) is technically valid Python but makes code nearly unreadable and is explicitly discouraged. Option B (2 spaces) is…

Huawei AI Development Platforms and Solutions

Question

How many spaces does PEP 8 stipulate that Python's first fine indentation needs to indent?

Options

  • A1
  • B2
  • C4
  • D8

How the community answered

(39 responses)
  • A
    13% (5)
  • B
    5% (2)
  • C
    79% (31)
  • D
    3% (1)

Explanation

PEP 8, Python's official style guide, stipulates 4 spaces per indentation level as the standard for Python code, making C the correct answer. Option A (1 space) is technically valid Python but makes code nearly unreadable and is explicitly discouraged. Option B (2 spaces) is common in other languages like JavaScript but is not the PEP 8 recommendation for Python. Option D (8 spaces) was historically used in some Unix/C traditions but creates excessive horizontal nesting in Python. A helpful memory tip: think of the 4 in "Python" - both have four letters in their core identity (Py-th-on = 6, but PEP 8 → 8 ÷ 2 = 4), or simply remember "Python = 4 spaces" as a direct association.

Topics

#PEP 8#Python indentation#Code formatting#Python conventions

Community Discussion

No community discussion yet for this question.

Full H13-311_V3.5 Practice