Syntax
Code sample link: https://replit.com/@jjoco/python-syntax
One of Python's main features is its readability. Consider the following pseudocode:
1 2 |
|
1 2 |
|
Compared to to other languages, there is no curly brackets to wrap code code blocks; instead, Python interprets code blocks via colons and indentation.
Indentation
Statements are interpreted in Python based on how indented they are. Unlike other programming languages in which indentation is technically optional, indentation in Python is used to interpret blocks of code. Take the following example:
1 2 3 4 5 6 |
|
Comments
Like in other languages, comments are implemented in Python to denote statements that are not to be interpreted and are for developer documentation. Single line comments are written like the following with the #
prefix:
1 |
|
1 2 3 4 5 6 7 8 |
|