ML 160: GitHub Copilot (15 pts)

What You Need

Purpose

To start using GitHub Copilot, which is free for students.

Making a GitHub Account

In a Web browser, go to
https://github.com/
If you don't already have a GitHub account using your student email, at the top right, click "Sign up". Create an account using your student email address.

If you already have a GitHub account using your student email, at the top right, click "Sign in". Sign in.

Joining GitHub Education

In a Web browser, go to
https://github.com/edu/students
In the center, click the "Join GitHub Education" button.

Follow the on-screen prompts to join the program.

Using GitHub Copilot

In a Web browser, go to
https://github.com/
At the top right, click your face. Click "Your Copilot".

On the next page, you should see that you are eligible to use Copilot for free, as shown below.

Click the "Get access to GitHub Copilot" button.

On the "Select your preferences" page, in the "Suggestions matching public code" line, select Allowed.

Click the "Save and complete setup" button.

Installing Visual Studio Code

In a Web browser, go to
https://code.visualstudio.com/Download
Download and install the correct version for your operating system.

Visual Studio Code launches, as shown below.

Installing the GitHub Copilot extension in Visual Studio Code

In Visual Studio Code, on the left side, click the lowermost icon to see Extensions.

Search for copiplot

In the "GitHub Copilot" box, click the Install button, as shown below.

When you are prompted to, sign in to your GitHub account.

Getting Started Video

In Visual Studio Code, on the right side, click the "Getting Started Videos" button, as shown below.

You see a "Getting started with GitHub Copilot" page containing videos. Watch the first lesson video.

Here are the main points from that video:

Creating a New File

In Visual Studio Code, on the right side, in the "GitHub Copilot" pane, scroll down and click "Mark Finished".

The right pane now shows a "Visual Studio Code" pane, as shown below.

Testing for Prime Numbers

Click "New File...".

At the top center, enter a file name of count.py as shown below.

Press Enter.

Navigate to a folder for your file and click the "Create File" button.

When a box pops up in the lower right offering to install a Python extension, as shown below, click Install and perform the installation.

In the "count.py" pane on the right side, type this line, and press Enter:
def is_prime(n):
Code appears to execute a very primitive test of primality, as shown below.

Press Tab to accept the code.

Press Enter twice to move to an empty line at the bottom.

Type this line, and press Enter:

# input integer from user
Code appears. Press Tab to accept the code.

Press Enter twice to move to an empty line at the bottom.

Type this line, and press Enter:

# test to see if num is prime
Code appears. Press Tab to accept the code.

Running the Code

On the left side, click the icon with a triangle pointing to the right, outlined in yellow in the image below.

Click the blue "Run and Debug" button.

At the top center, click "Python debugger".

Click "Python debugger: Debug the currently active Python file".

A Python Debug Console pane opens at the lower right. At the "Enter an integer:" prompt, type

100
Press Enter.

The program ends without printing anything, as shown below.

This is correct behavior--it only prints a message if the number is prime.

Run the code again. This time enter this number:
101
The output says "101 is prime", as shown below.

This is correct behavior--it only prints a message if the number is prime.

ML 160.1: List all Prime Factors (15 pts)

From the File menu, create a new file named list_factors.py.

Write a program that will list all the factors of a number, as shown below. This should be very easy to do.

Run the program and enter this integer:

12345
The flag is covered by a green rectangle in the image below.

Posted 5-21-24