Create or extend a ready-to-use repository for teaching Python in minutes
- Who is this for? Educators of all levels.
- How much experience do students need? Zero. This template is built with basic elements complete with comments so it can be used in beginner to advanced lessons.
- Prerequisites: None. This template will provide a working Jupyter Notebook with Pandas using a dataset so that you can immediately start analyzing data as well as an example Notebook that you can use to teach Python with GitHub Copilot, a powerful AI tool that helps you write code faster.
With this template repository you can quickly create a normalized environment to teach or learn Python. Make your students focus on learning rather than setting up their environment. This template uses Codespaces, a development environment that's hosted in the cloud with Visual Studio Code, a powerful text editor.
You'll also get the chance to try out Copilot to create a lesson plan using the example-lesson.ipynb file.
🤔 Curious? Watch the following video where we explain all the details:
🚀 Codespaces features:
- Repeatable cloud environment offering a push-button experience.
- Can be configured and customized.
- Integrates with your repositories on GitHub and VSCode
As a teacher that means that you can create an environment, in the cloud, for your class that all students can use with zero or next to zero configuration regardless of what operating system they are using.
A Codespace is a development environment that's hosted in the cloud that you can configure. The Codespaces Education benefit gives Global Campus teachers a free monthly allowance of GitHub Codespaces hours to use in GitHub Classroom. Learn more here about Using GitHub Codespaces with GitHub Classroom.
If you are not already a Global Campus teacher, apply here or for more information, see Apply to GitHub Global Campus as a teacher.
Customize your project for GitHub Codespaces by committing configuration files to your repository (often known as Configuration-as-Code), which creates a repeatable codespace configuration for all users of your project.
You can configure things like:
- Extensions, you can specify what extensions should be preinstalled.
- Dotfiles and settings.
- Operating system libraries and dependencies
💡 Learn more about customization and configuration in the official documentation
This repo is a GitHub template. It contains the following:
- example-notebook.ipynb: A Jupyter notebook using the Pandas library to teach basic operations with a small CSV (Comma Separated Value file) dataset
- .devcontainer/Dockerfile: Configuration file used by Codespaces to determine operating system and other details.
- .devcontainer/devcontainer.json, A configuration file used by Codespaces to configure Visual Studio Code settings, such as the enabling of additional extensions.
README.md
. This file describes this repository and what's in it.
Try out this template repository using Codespaces following these steps:
- Create a repository from this template. Use this create repo link. You can make the repository private or public, up to you.
- Navigate to the main page of the newly created repository.
- Under the repository name, use the Code drop-down menu, and in the Codespaces tab, select "Create codespace on main".
- Wait as Github initializes the codespace:
What you have at this point is a pre-configured environment where all the runtimes and libraries you need are already installed - a zero config experience.
You also have a Jupyter Notebook that you can start using without any configuration.
This environment will run the same regardless of whether your students are on Windows, macOS or Linux.
Open up your Jupyter Notebook file example-notebook.ipynb and note how you can add code and run it.
Let's make changes to your environment. We'll cover two different challenges that you are likely to want to do:
- Change the Python version installed
- Add an extension
Let's say you want to change what version of Python is installed. This is something you can control.
Open .devcontainer/devcontainer.json and replace the following section:
"VARIANT": "3.8-bullseye"
with the following instruction:
"VARIANT": "3.9-bullseye"
This change instructs Codespaces to use Python 3.9 instead of 3.8.
If you make any configuration change in devcontainer.json
, a box will appear after saving.
Click on rebuild. Wait for your Codespace to rebuild the VS Code environment.
Your environment comes with pre-installed extensions. You can change which extensions your Codespaces environment starts with. Here's how:
-
Open file .devcontainer/devcontainer.json and locate the following JSON element extensions:
"extensions": [ "ms-python.python", "ms-python.vscode-pylance" ]
-
Add "ms-python.black-formatter" to the list of extensions. It should end up looking like the following:
"extensions": [ "ms-python.python", "ms-python.vscode-pylance", "ms-python.black-formatter" ]
That string is the unique identifier of Black Formatter, a popular extension for formatting Python code according to best practices. Adding the "ms-python.black-formatter" identifier to the list lets Codespaces know that this extension should be pre-installed upon startup.
Remainder: When you change any configuration on the json, a box will appear after saving.
Click on rebuild. Wait for your codespace to rebuild the VS Code environment.
To find the unique identifier of an extension:
- Navigate to the extension's web page, for example https://marketplace.visualstudio.com/items?itemName=ms-python.black-formatter
- Locate the Unique Identifier field under More info section on your right side.
GitHub Copilot is now available in GitHub Codespaces. You can use Copilot to create a lesson for your students. This repository includes the extension for Copilot so that you can use it right away. Make sure your account has access to Copilot. If you don't have access, you can request access here.
GitHub Copilot is free for students and faculty. Learn more. Follow these steps to verify your student or faculty membership and enable Copilot for free.
Open the example-notebook.ipynb file and write a description for your lesson in the first cell. Make sure Copilot is enabled by clicking on the Copilot icon in the status bar and ensuring you're logged into GitHub.
Edit the first cell and start typing For this lesson
. Copilot will suggest a description for your lesson. Select the suggestion and press Tab
to accept it.
The cell should now look similar to this:
# Create a lesson using GitHub Copilot
For this lesson, you'll use GitHub Copilot to create a lesson for students to learn how to write functions in Python. You'll use Copilot to write code, and you'll use Copilot to write text.
It is OK if Copilot doesn't suggest an exact replica of the text above. You can edit the text to make it more suitable for your lesson.
Add a new cell below the description cell and start typing ### Step 1: Enable
to create a new step in your lesson. Copilot will suggest a step for your lesson. Select the suggestion and press Tab
to accept it.
The cell should now look similar to this:
## Step 1: Enable GitHub Copilot
Enable Copilot by following the instructions in the [GitHub Copilot documentation](https://docs.github.com/en/codespaces/developing-with-codespaces/using-codespaces-with-github-copilot). If you are a student, you can get a free [GitHub Student Developer Pack](https://education.github.com/pack) to get access to Copilot.
Keep adding more steps and continue typing to get more accurate suggestions for the content you are interested in. For example, this is a step that Copilot suggested for the next step in the lesson:
## Step 3: Create challenges for this lesson
You'll teach students how to write functions in Python.
You can use the example above to see what Copilot can suggest and auto-complete. Feel free to add as many steps as you think are necessary for your lesson.
Add a new code cell below the last step and start with a Python comment that describes the challenge. For example, you can write # create a challenge for a student to write a function that returns the sum of two numbers
. Copilot will suggest a solution for the challenge. Select the suggestion and press Tab
to accept it. For every new line, you can press Return
(or Enter
) to get a new suggestion.
This is a sample of what Copilot suggested for the challenge above:
# create a challenge for a student to write a function that returns the sum of two numbers
"""
In this challenge, you'll write a function that returns the sum of two numbers.
You'll use the `sum` function to add the two numbers.
Start by writing a function that takes two numbers as parameters.
Then, use the `sum` function to add the two numbers.
Finally, return the sum of the two numbers.
"""
Again, your challenge may not be exactly the same as the one above. You can edit the challenge to make it more suitable for your lesson.
Create as many code cells with example prompts for your lesson.
Add a new cell below for writing Markdown (not code!) and start by writing ### Quiz
. Then add an HTML comment to create a prompt so that GitHub Copilot understands what type of quiz you want to create. For example, you could use something similar to this:
<!-- generate a quiz of 5 questions about using Python functions with a mix of variable arguments and keyword arguments -->
Copilot might not suggest a quiz for you right away. If that's the case, add new lines to the comment and press Return
(or Enter
) and start enumerating the questions you want to ask. For example, you could write:
1. What is the output of the following code?
Of if you are looking for a specific question about a topic it could be:
2. When you create a function that
Copilot suggested a question using variable arguments which is what the challenge is about:
2. When you create a function that accepts a variable number of arguments, what is the name of the parameter that you use to access the arguments?
Finally, review the cells and make changes as necessary. You can also add more steps, challenges, and questions to your lesson.
Congratulations! You've created a lesson for students to learn how to write functions in Python using GitHub Copilot. You can use Copilot to assist you in documentation, writing examples, or challenges like in this repository. Even this whole section was written using Copilot!
- GitHub Codespaces docs overview
- GitHub Codespaces docs quickstart
- Using GitHub Codespaces with GitHub Classroom
Help us make this template repository better by letting us know and opening an issue!.