4.1.2
Whitespace
Whitespace
Whitespace
Whitespace is key to Python, since it is used to separate blocks of code.
![Illustrative background for Indentation](https://image-v2.cdn.app.senecalearning.com/2018-07/95d17dd9-261f-4238-9065-f411ea8c7210/code-Data-Computer-Wifi-Internet,h_400,q_80,w_640.jpg)
![Illustrative background for Indentation ?? "content](https://image-v2.cdn.app.senecalearning.com/2018-07/95d17dd9-261f-4238-9065-f411ea8c7210/code-Data-Computer-Wifi-Internet,h_400,q_80,w_640.jpg)
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.
![Illustrative background for Blank lines](https://image-v2.cdn.app.senecalearning.com/2018-09/178d1db7-42b2-4c46-8b41-ab363455de22/code-on-laptop,h_400,q_80,w_640.jpeg)
![Illustrative background for Blank lines ?? "content](https://image-v2.cdn.app.senecalearning.com/2018-09/178d1db7-42b2-4c46-8b41-ab363455de22/code-on-laptop,h_400,q_80,w_640.jpeg)
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.
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
![Go student ad image](/en-GB/revision-notes/_next/image?url=%2Fen-GB%2Frevision-notes%2Fimages%2Fgo-student-uk-ad.jpg&w=640&q=100)
Unlock your full potential with GoStudent tutoring
Affordable 1:1 tutoring from the comfort of your home
Tutors are matched to your specific learning needs
30+ school subjects covered