Skip to content

CarlosDanieel/Codespace_Learn_Python

Repository files navigation

Open in GitHub Codespaces

Python Codespace Template

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:

Teaching Python with Codespaces

πŸŽ₯ Watch the video tutorial to learn more about Codespaces

Codespaces Tutorial

πŸš€ 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.

πŸ§‘β€πŸ« What is GitHub Codespace and how can I use it in my teaching?

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.

Customization

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

Codespaces template

This repo is a GitHub template. It contains the following:

🧐 Try it out

Try out this template repository using Codespaces following these steps:

  1. Create a repository from this template. Use this create repo link. You can make the repository private or public, up to you.
  2. Navigate to the main page of the newly created repository.
  3. Under the repository name, use the Code drop-down menu, and in the Codespaces tab, select "Create codespace on main". Create codespace
  4. Wait as Github initializes the codespace: Creating codespace

Inspect your codespaces environment

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.

Customize the Codespace

Let's make changes to your environment. We'll cover two different challenges that you are likely to want to do:

  1. Change the Python version installed
  2. Add an extension

Step 1: Change the Python environment

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.

Recreating Codespace

Click on rebuild. Wait for your Codespace to rebuild the VS Code environment.

Step 2: Add an extension

Your environment comes with pre-installed extensions. You can change which extensions your Codespaces environment starts with. Here's how:

  1. Open file .devcontainer/devcontainer.json and locate the following JSON element extensions:

    "extensions": [
     "ms-python.python",
     "ms-python.vscode-pylance"
    ]
  2. 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.

    Reacreating codespace

    Click on rebuild. Wait for your codespace to rebuild the VS Code environment.

To find the unique identifier of an extension:

πŸ€– Use Copilot to create a lesson for students

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.

Step 1: Write a description for your lesson

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.

Step 2 Add steps to 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.

Step 3: Add code challenges for students

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.

Step 4: Create a quiz for students

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!

Learn more

πŸ”Ž Found an issue or have an idea for improvement?

Help us make this template repository better by letting us know and opening an issue!.

About

MS Codespace to lean about python

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published