Python Programming – Python Style Rules and Conventions

You can learn about Introduction to Python Programming Programs with Outputs helped you to understand the language better.

Python Programming – Python Style Rules and Conventions

summarizes the list of some of the Python style rules and conventions.

Elements Description
Semicolons The Python statement written in the form of a sentence must not be terminated with semicolons. Semicolons should not be used as separators to put two com­mands on the same line.
Line length The line length should be of maximum 79 characters if you use Python.
Indentation In Python, indentation is used to form suites, i.e., block of statements, and it is treated as a unit. The code blocks are indented with spaces.
Blank Lines The two blank lines should be between top-level definitions, and one blank line should be between method definitions.
Whitespace Standard typographic rules are used for spaces around punctuation.
Comments The right style for module, function, method, and in-line comments should always be used.
Statements Generally, only one statement per line should be written.
Case Sensitive Python is case sensitive, i.e., it treats upper and lower case characters differently. Therefore, case of statement is very important. Always be careful while declar­ing code and identifier names.

Recommended Reading On: Python Program to Check Whether Triangle is Valid or Not if Sides are Given

Leave a Reply

Your email address will not be published. Required fields are marked *