Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/02-Python Statements/01-Introduction to Python Statements.ipynb
Views: 648
Introduction to Python Statements
In this lecture we will be doing a quick overview of Python Statements. This lecture will emphasize differences between Python and other languages such as C++.
There are two reasons we take this approach for learning the context of Python Statements:
Python vs Other Languages
Let's create a simple statement that says: "If a is greater than b, assign 2 to a and 4 to b"
Take a look at these two if statements (we will learn about building out if statements soon).
Version 1 (Other Languages)
Version 2 (Python)
You'll notice that Python is less cluttered and much more readable than the first version. How does Python manage this?
Let's walk through the main differences:
Python gets rid of () and {} by incorporating two main factors: a colon and whitespace. The statement is ended with a colon, and whitespace is used (indentation) to describe what takes place in case of the statement.
Another major difference is the lack of semicolons in Python. Semicolons are used to denote statement endings in many other languages, but in Python, the end of a line is the same as the end of a statement.
Lastly, to end this brief overview of differences, let's take a closer look at indentation syntax in Python vs other languages:
Indentation
Here is some pseudo-code to indicate the use of whitespace and indentation in Python:
Other Languages
Python
Note how Python is so heavily driven by code indentation and whitespace. This means that code readability is a core part of the design of the Python language.
Now let's start diving deeper by coding these sort of statements in Python!