Python Notebooks
1 Notebooks
To discover Python, we will start by coding in these 5 notebooks:
- Types and variables
- Lists and dictionaries
- Loops
- Functions
- Introduction to Object-Oriented Programming
To create these notebooks, I was inspired by the resources below:
- Introduction to Python training from the INSEE SSP Cloud
- Python Course from Université Paris Cité
2 Using a notebook
- Start by going to one of the 5 notebooks mentioned above
- Download the
.ipynbfile to your machine - Connect to one of the services offered below
- Upload the
.ipynbfile to this service
2.1 Launching a Jupyter service
In the left column:
- the folder icon allows you to browse files
- the list icon allows you to display the table of contents
The Code field indicates whether the cell expects Python code or text (Markdown)
Here are other possibilities for using a notebook:
- the GENES datalab
- an ENSAI Jupyter cluster ➡️ if you have your username and password
- Jupyter Lab online
- Kaggle notebooks
- Google Colab
2.2 Cell types
A notebook is made up of cells. You can create a new cell by clicking on the + button in the toolbar. There are two main types of cells:
- code cells (where you write and execute Python code)
- text cells (where you write formatted text using Markdown)
It is a simple and intuitive language that allows you to format text (this website is generated with Markdown code).
Many resources are available on the internet, for example
Some examples:
| Code | Formatting |
|---|---|
**bold text** |
bold text |
*italic text* |
italic text |
# Level 1 title |
|
## Level 2 title |
|
- Bullet point item |
- Bullet point item |
The desired cell type can be changed in the toolbar.
3 Useful commands
| Command | Description |
|---|---|
SHIFT + ENTER |
Execute a cell and move to the next one. |
CTRL + ENTER |
Execute a cell without moving to the next one. |
ESC |
Switch to command mode (cell borders become blue). |
ENTER |
Switch to edit mode (you can modify the cell content). |
A |
Insert a cell above the current cell. |
B |
Insert a cell below the current cell. |
D + D |
Delete a cell. |
4 Useful resources
You will find more information about notebooks on the INSEE Python introductory training website.