4.1.2
Whitespace
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 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
- 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.
1Introduction to Python
1.1Python
1.2Input & Output
1.3Data Types
1.4Variables & Constants
1.6Program Flow
2Data Structures
2.1Lists & Strings
2.2File Handling
3Modularity
3.1Subroutines
3.2Data Flow
4Good Practice
4.1Naming & Whitespace
4.2Comments
4.3Exceptions
Jump to other topics
1Introduction to Python
1.1Python
1.2Input & Output
1.3Data Types
1.4Variables & Constants
1.6Program Flow
2Data Structures
2.1Lists & Strings
2.2File Handling
3Modularity
3.1Subroutines
3.2Data Flow
4Good Practice
4.1Naming & Whitespace
4.2Comments
4.3Exceptions
Practice questions on Whitespace
Can you answer these? Test yourself with free interactive practice on Seneca — used by over 10 million students.
- 1Why is it always a good idea to use indentation?Multiple choice
- 2Can blank lines be used within subroutines?Multiple choice
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