Newer
Older
This repository contains several notebooks to help you learn the basics of the Python programming
language and some tutorials and example commands to know how to run code.
## Table of content
- [Running the notebooks](#running-the-notebooks-toc)
- [On the Jupiter platform at ISAE](#on-the-jupiter-platform-at-isae-toc)
- [Locally on your personal computer](#locally-on-your-personal-computer-toc)
- [Locally on ISAE's computers](#locally-on-isaes-computers-toc)
- [The Python notebooks](#the-python-notebooks-toc)
- [The _basics_ of the language](#the-basics-of-the-language-toc)
- [Reading _text files_ and writing _functions_](#reading-text-files-and-writing-functions-toc)
- [Manipulating _JSON_, _CSV_ and _dictionaries_](#manipulating-json-csv-and-dictionaries-toc)
- [_Object-oriented_ programming](#object-oriented-programming-toc)
- [Some advanced features of Python](#some-advanced-features-of-python-toc)
## Running the notebooks [[toc](#table-of-content)]
To run the notebooks, you have several options:
### On the Jupiter platform at ISAE [[toc](#table-of-content)]
The first one is to use the [Jupyter platform at ISAE](https://jupyter.isae.fr).
You can log in with your ISAE credentials and upload the notebooks to the platform.
To upload the notebooks, you can use the following steps:
- open a _Console_ in the Jupyter platform
- clone this repository using the following command:
```bash
git clone https://gitlab.isae-supaero.fr/mae-ac/learn-python.git
```
- open the `learn-python/` directory in the Jupyter platform
### Locally on your personal computer [[toc](#table-of-content)]
First, clone the repository on your computer using the following command:
```bash
git clone https://gitlab.isae-supaero.fr/mae-ac/learn-python.git
```
or by using an IDE, e.g. VSCode, if it supports this feature.
To run the notebooks locally, you need to have Python installed on your computer. You can download
it from the [official website](https://www.python.org/downloads/).
> :bulb: **Note**
>
> - if you are on Linux, you should be able to install Python with the package manager of your
> distro, e.g. `apt` for Ubuntu
> - if you are on Windows, VSCode should be able to take care of Python, otherwise, you might want
> to install Anaconda
You also need to install the Jupyter notebook package. You can install it using the following
command:
```bash
pip install jupyter
```
Then, you can run the Jupyter notebook server by running the following command in the root directory
of this repository:
```bash
jupyter notebook
```
Now, you can open the notebooks in your browser and run them.
### Locally on ISAE's computers [[toc](#table-of-content)]
You can also run the notebooks on the computers at ISAE. You can use the following steps:
- open a _Terminal_ on the computer
- clone this repository using the following command:
```bash
git clone https://gitlab.isae-supaero.fr/mae-ac/learn-python.git
```
- go inside the repository with
```bash
cd learn-python
```
> :bulb: **Note**
>
> in the last two steps, you can replace "learn-python" by any of the
> [project names of the class](https://gitlab.isae-supaero.fr/mae-ac), e.g. "trees" for TP4
- load the _Anaconda_ module using the following command:
- activate the _Jupyter_ environment using the following command:
```bash
source activate mae1-env
```
- Run jupyter notebook using the following command:
```bash
jupyter notebook
```
> :bulb: **Note**
>
> you can also run any command you like, e.g. opening VSCode from inside of the Python environment
> activated in previous steps:
> ```shell
> code .
> ```
> or run Python directly
> ```shell
> python some_script.py
> ```
## The Python notebooks [[toc](#table-of-content)]
### The _basics_ of the language [[toc](#table-of-content)]
Open the [first notebook](notebooks/01_python_basics.ipynb). By completing it, you will learn the
basic concepts of Python :
- variables
- conditions, loops, ...
- strings, dictionaries, ...
### Reading _text files_ and writing _functions_ [[toc](#table-of-content)]
The [second notebook](notebooks/02_text_files_and_functions.ipynb) presents a set of Python features
that should help you to improve your code :
- reading and writing to text files on the disk
- writing functions
Please use the [`austen-emma.txt`](data/austen-emma.txt) and
[`austen-emma-excerpt.txt`](data/austen-emma-excerpt.txt) files.
> you can find all the data files in the [`data/`](data/) directory and you can use these files from
> any notebook in [`notebooks/`](notebooks/) with [`data/`](data/)
### Manipulating _JSON_, _CSV_ and _dictionaries_ [[toc](#table-of-content)]
JSON is a ubiquitous file format because it is so human-readable and simple.
CSV is also used a lot to store tabular data.
Open the [third notebook](notebooks/03_json_csv.ipynb) and fill it . You will use the files
[`example.json`](../data/example.json) and [`example.csv`](../data/example.csv) stored in the
[`data/`](data/) directory.
### _Object-oriented_ programming [[toc](#table-of-content)]
Most of the main concepts of Classes and objects are presented in the
[fourth notebook](notebooks/04_object_oriented_programming.ipynb). Please, read and fill it.
### Some advanced features of Python [[toc](#table-of-content)]
Some advanced features of Python are presented in the [fifth notebook](notebooks/05_advanced.ipynb)