In this 4-hour workshop, participants will be introduced to the basics of programming in Python. Students will journey from the beginnings of creating variables and performing simple mathematical operations to writing code that can perform fundamental tasks and wrapping this code into functions. Participants will learn how to write the important building blocks that make up complex programs.
- Store data in variables and collections.
- Perform basic operations on these data.
- Use control flow and loops to write powerful code.
- Define functions to create repeatable units of behaviour.
- Basic computer science knowledge of data types and control structures.
- No prior programming experience is required, but knowing another language may help.
- To be able to participate in the exercises, participants must
either:
- Have a local installation of Python and Jupyter notebooks. Microsoft Visual Studio Code with the Python extension installed can also be used to run the Notebook.
- Have a Google Account (to run in-browser as a Colab notebook)
See SETUP.md for full setup information. After setting up Python, you can download the material as a ZIP file using the green button higher up on this page, or by cloning this repository:
git clone https://github.com/bzrudski/Intro-to-Python.git
To take full advantage of this interactive workshop, you must have access to a Python environment and Jupyter Lab.
The required steps depend on how you installed Python:
- (Recommended) If you installed minconda, you can easily install Jupyter Lab by running the following on the command line:
conda install -c conda-forge jupyterlab
- If you installed Python from the official website, you can easily install Jupyter using
pip
by running the following on the command line:
pip install jupyterlab
- If you installed Anaconda, you already have Jupyter Lab installed.
For more details on installing Jupyter Lab, see https://jupyter.org/install.
Once you have Jupyter installed, open the Intro-to-Python
folder on your computer and launch Jupyter Lab by typing:
jupyter lab
Then you can open the Jupyter notebook files.
If you don't want to install anything locally, you can open the workshop materials using Google Colab:
- Student version (with blank fields): https://colab.research.google.com/github/bzrudski/Intro-to-Python/blob/main/Exercises/scripts/IntroToPythonBZR.ipynb
- Solution version (filled out): https://colab.research.google.com/github/bzrudski/Intro-to-Python/blob/main/Exercises/solutions/IntroToPythonBZR.ipynb
For a more detailed outline, see Outline/Intro-to-Python-Outline.md.
- Module 1 -- Python Basics
- Module 2 -- Strings and Collections: An Object Primer
- Module 3 -- Introduction to Functions
- Module 4 -- Where to go from here
This workshop is based on my previous iterations of the workshop, which can be found at the following repositories:
- Intro to Python - Fall 2024
- Intermediate Python - Fall 2024
- Summer 2024
- Winter 2024
- Summer 2023
- Fall 2022
Colab badge created using https://shields.io.
Workshop created as part of the McGill Initiative in Computational Medicine.
For more information about the QLS-MiCM, visit: https://www.mcgill.ca/micm/.
The contents of this repository are licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.