[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/varyumin/learn-python/master/src/getting_started/python_syntax.md [Back]  [Original]

# Python Syntax

**Python Syntax compared to other programming languages**

- Python was designed to for readability, and has some similarities to the English language with influence from mathematics.
- Python uses new lines to complete a command, as opposed to other programming languages which often use semicolons or parentheses.
- Python relies on indentation, using whitespace, to define scope; such as the scope of loops, functions and classes. Other programming languages often use curly-brackets for this purpose.

## Python Indentations

Where in other programming languages the indentation in code is for readability only, in Python the indentation is very important.

Python uses indentation to indicate a block of code.

```python
if 5 > 2:
  print("Five is greater than two!")
```

Python will give you an error if you skip the indentation.

## Comments

Python has commenting capability for the purpose of in-code documentation.

Comments start with a `#`, and Python will render the rest of the line as a comment:

```python
#This is a comment.
print("Hello, World!")
```

## Docstrings

Python also has extended documentation capability, called docstrings.

Docstrings can be one line, or multiline. Docstrings are also comments:

Python uses triple quotes at the beginning and end of the docstring:

```python
"""This is a 
multiline docstring."""
print("Hello, World!")
```

## References

- [w3schools.com](https://www.w3schools.com/python/python_syntax.asp)

Web Proxy Viewer  |  New URL  |  Original Page