Recap Python Basics
This lesson contains a curated collection of Jupyter Notebooks of introductory materials about programming in Python.
Python Refresher as Jupyter Notebooks
In the previous sections you should have installed all required packages for your conda environment, including the Jupyter notebook server.
Create a folder named L0
in your geopython2023 working directory.
Download the linked .ipynb files (Jupyter Notebook files) - right click on the links below (Chapter 1, Chapter 2 etc) and save them into your geopython2023/L0
folder. Go back into the console/commandline prompt, make sure you are in the directory where you extracted the materials. Then you should start the Jupyter notebook server in this geopython2023
base directory.
- Open Powershell
- activate
geopython2023
environment - navigate into the
geopython2023
folder - start Jupyter notebook server (aka jupyter lab)
All you need to do to play notebooks is to type the following command in your project folder:
cd C:\Users\Alexander\geopython2023
(geopy2023) jupyter lab
A browser window will open, with the files listed from your geopython2023
folder and you will see the L0
directory. In order to start a Notebook, click on the folder to step into the L0
folder and click on the respective .ipynb file. This will open a new tab in the browser and now you have a running Jupyter notebook session. Cells are typically either Code (Python) that you can run/execute, or descriptive text in Markdown format. To download the notebook file you likely want to “right-click” on the link and select “Save Link As” or similar.
Chapter 1: Variables, Strings and Numbers.ipynb In this section, you will learn to store information in variables.
Chapter 2: Lists, Tuples and Sets.ipynb In this notebook, you will learn to store more than one valuable in a single variable.
Chapter 3: If Statements In this section, you will learn how to test for certain conditions, and then respond in appropriate ways to those conditions.
Chapter 4: Loops and Input.ipynb While loops are really useful because they let your program run until a user decides to quit the program. They set up an infinite loop that runs until the user does something to end the loop. This section also introduces the first way to get input from your program's users.
Chapter 5: Dictionaries.ipynb (Data Structures) Dictionaries allow us to store connected bits of information. For example, you might store a person's name and age together.
Chapter 6: Introducing Functions.ipynb Functions mean less work for us as programmers, and effective use of functions results in code that is less error-prone.
Chapter 7: Classes and OOP.ipynb In this section you will learn about the last major data structure, classes. Classes are quite unlike the other data types, in that they are much more flexible. Classes allow you to define the information and behavior that characterize anything you want to model in your program.
Chapter 8: Exceptions.ipynb Exceptions which are events that can modify the flow of control through a program. In Python, exceptions are triggered automatically on errors, and they can be triggered and intercepted by your code.
Appendix: Python Coding Style.ipynb You are now starting to write Python programs that have a little substance. Your programs are growing a little longer, and there is a little more structure to your programs. This is a really good time to consider your overall style in writing code.
License and Sharing Material
Valerio Maggio https://github.com/leriomaggio/python-in-a-notebook
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.