Test your knowledge with free interactive questions on Seneca — used by over 10 million students.

Whitespace

Whitespace is key to Python, since it is used to separate blocks of code.

Indentation

Indentation

  • Indentation is necessary in Python to control program flow.
  • Even in languages where it is optional, it is best practice since it makes code more readable.
Blank lines

Blank lines

  • Sometimes blank lines can be used to make code more readable.
  • In Python, the guidelines are:
    • Subroutines should be separated by a blank line.
    • Blank lines can be used sparingly in subroutines to show sections of the subroutine.
    • Other lines of code should not have blank space around them.
Jump to other topics
1

Introduction to Python

2

Data Structures

2.1

Lists & Strings

2.2

File Handling

3

Modularity

3.1

Subroutines

3.2

Data Flow

4

Good Practice

4.1

Naming & Whitespace

4.2

Comments

4.3

Exceptions

Practice questions on Whitespace

Can you answer these? Test yourself with free interactive practice on Seneca — used by over 10 million students.

  1. 1
  2. 2
Answer all questions on Whitespace

Unlock your full potential with Seneca Premium

  • Unlimited access to 10,000+ open-ended exam questions

  • Mini-mock exams based on your study history

  • Unlock 800+ premium courses & e-books

Get started with Seneca Premium