"The book or Python guide is split into lessons and exercises. Lessons are mostly theoretical, though they contain code that you can change and execute to help you understand the lesson. \n",
"Exercises are meant to help you practice what you learned in the corresponding lesson."
"Lessons contain code that you can change and execute to help you understand the lesson. Try to play around with the code and see what happens. This is the best way to understand it. If you mess-up the code too much, you can always `git checkout <path_to_modified_file>` to revert it to the original state (since this is a git repo). Or you can re-clone a fresh copy of the repo.\n",
"\n",
"Don't forget to pull new updates / lessons. \n",
"\n",
"If you need some help with *git*:\n",
"\n",
"[What is git?](https://www.atlassian.com/git/tutorials/what-is-git)\n",
"Since you are seeing this notebook, I guess you've already find a way to somehow view it. Nonetheless, here is a way to run it locally on your computer in \"interactive\" mode.\n",
"\n",
"### Installation\n",
"\n",
"1) Clone the repo from Github (if you haven't already):\n",
"The `-e` flag tells pip to install the package in *editable mode* - it uses the current directory as a source for the package. Therefore, any changes you make to the package will be reflected immediately. (Otherwise, you would have to re-install the package after every change or modify files in Python's `site-packages` directory.)\n",
"\n",
"### Usage\n",
"\n",
"This runs this notebook with basic instructions:\n",
"```{code-cell}\n",
"python -m pge_lectures\n",
"```\n",
"\n",
"This runs a specific lesson:\n",
"```{code-cell}\n",
"python -m pge_lectures <lesson_number>\n",
"```\n",
"Substitute <lesson_number> with the number of the lesson you want to run. Alternatively, you can list all available lessons with:\n",
"\n",
"```{code-cell}\n",
...
...
%% Cell type:markdown id: tags:
For those who don't know, this is what is called a "Jupyter notebook". It is kind of like a web page that a mixes code and markdown formatted text. It is divided into "cells". Each cell can be either text cell (using markdown format) or code cell, containing executable Python code. When executed, the text cells simply render the formatted text. However, the code cells will actually run the code and print the result below that cell.
Important to keep in mind is that actual Python "kernel" is running in the background. Whatever you run, "stays" in the kernel (until it is stopped or restarted). For example, if you run a cell defining a variable `a = 3`, you can then use the variable in another cell, e.g., `b = a + 5` (without redefining it in that cell). However, the order of the cells in the document does not matter. What matters is the order in which you execute the cells. Therefore, if you run the cell containing `b = a + 5` before the cell containing `a = 3`, it will throw an error stating that variable `a` does not exist. Likewise, if you execute another cell with `a = 7`, it will rewrite the value of `a` and thus `b = a + 5` will result in `b` having a different value.
Keep this in mind when executing individual cells. My recommendation is to always run the cells in consecutive order and re-run them from the beginning again, if you close a file and open it later.
Lastly, we will use the `print()` function heavily. It simply prints whatever is in the brackets. Either a direct value or a result of an operation. E.g., `print(5 + a * 2)` will print `11` below the cell (provided a==3). Multiple prints within the same cell are simply stacked one after another.
Because it is "a live code", you can also modify it, play with it, to explore the examples yourself. Hopefully, this will help you understand everything more.
I hope everything is clear and it will prove useful to you.
%% Cell type:markdown id: tags:
## How to read this "book"
The book or Python guide is split into lessons and exercises. Lessons are mostly theoretical, though they contain code that you can change and execute to help you understand the lesson.
Exercises are meant to help you practice what you learned in the corresponding lesson.
Lessons contain code that you can change and execute to help you understand the lesson. Try to play around with the code and see what happens. This is the best way to understand it. If you mess-up the code too much, you can always `git checkout <path_to_modified_file>` to revert it to the original state (since this is a git repo). Or you can re-clone a fresh copy of the repo.
Don't forget to pull new updates / lessons.
If you need some help with *git*:
[What is git?](https://www.atlassian.com/git/tutorials/what-is-git)
Since you are seeing this notebook, I guess you've already find a way to somehow view it. Nonetheless, here is a way to run it locally on your computer in "interactive" mode.
### Installation
1) Clone the repo from Github (if you haven't already):
The `-e` flag tells pip to install the package in *editable mode* - it uses the current directory as a source for the package. Therefore, any changes you make to the package will be reflected immediately. (Otherwise, you would have to re-install the package after every change or modify files in Python's `site-packages` directory.)
### Usage
This runs this notebook with basic instructions:
```{code-cell}
python -m pge_lectures
```
This runs a specific lesson:
```{code-cell}
python -m pge_lectures <lesson_number>
```
Substitute <lesson_number> with the number of the lesson you want to run. Alternatively, you can list all available lessons with: