Skip to content

Session 01 review #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions episodes/12-running-vscode.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ There are many other features and ways to access them, and we'll cover key ones

Extensions are a major strength of VSCode. Whilst VSCode appears quite lightweight, and presents a simple interface (particularly compared to many other IDEs!), this is quite deceptive.
You can extend its functionality in many different ways.
or example, installing support for other languages, greater support for version control, there's even support for working with databases, and so on.
For example, installing support for other languages, greater support for version control, there's even support for working with databases, and so on.
There are literally tens of thousands of possible extensions now.

Now VSCode already comes with built-in support for JavaScript, including TypeScript and node.js,
Expand All @@ -67,24 +67,24 @@ Installing a language extension will allow you to do more things with that parti

Let's install an extension now:

1. Firstly, select the extensions icon first, then type in Python into the search box at the top, and it'll give you a list of all python-related extensions.
1. Firstly, select the extensions icon, then type in "Python" into the search box at the top, and it'll give you a list of all Python-related extensions.
1. Select the one which says `Python` from Microsoft. This is the Microsoft official Python extension.
1. Then select `Install`.

It might take a minute - you can see a sliding blue line in the top left to indicate it's working.
Once complete, you should see a couple of "Welcome" windows introducing you to two of its key features - support for Python and Jupyter notebooks.
If you use Jupyter notebooks, which is a way of writing Python programs that you can run line by line from within an editor as you write the program, you may find this useful.

For now, let's configure this extension for our Python development, and to do that, we need to do is tell VSCode which Python installation on our machine we'd like it to use. In the Python Welcome window, select `Select a Python interpreter`, and then `Select Python interpreter`.
You may find you have many installations of Python, or only have one. Try to select one later than 3.8 if you can.
Then select `Mark done`, and close the welcome windows.
For now, let's configure this extension for our Python development, and to do that, we need to tell VSCode which Python installation on our machine we'd like it to use. In the Python Welcome window, select `Select a Python interpreter`, and then `Select Python interpreter`.
You may find you have many installations of Python, or only have one. Try to select the version later than 3.8 if you can.
Then select `Mark done`, and close the Welcome window.

## A Sample Project

FIXME: copy code-style-example repo to softwaresaved's organisation

Next, let's obtain some example Python and edit it from within VSCode.
So first, you can download the example code we'll use from https://github.com/UNIVERSE-HPC/code-style-example/releases/tag/v1.0.0, either as a `.zip` or `.tar.gz` compressed archive file.
First, download the example code we'll use from https://github.com/UNIVERSE-HPC/code-style-example/releases/tag/v1.0.0, either as a `.zip` or `.tar.gz` compressed archive file.
If you're unsure, download the `.zip` file.
Then, extract all the files from the archive into a convenient location.
You should see files contained within a new directory named `code-style-example-1.0.0`.
Expand All @@ -103,9 +103,9 @@ Note that we're looking for the *folder* that contains the files, not a specific

If your system has the Git version control system installed, you may see a `Clone Repository` option here too.
If you are familiar with Git and wish to use this option instead,
select this option instead and enter the repository's location as `https://github.com/UNIVERSE-HPC/code-style-example`.
select it and enter the repository's location as `https://github.com/UNIVERSE-HPC/code-style-example`.
Then use the file browser that is presented to find a convenient location to store the cloned code and click on `Select as Repository Destination`,
then select `Open` when ‘Would you like to open the cloned repository?' appears.
then select `Open` when ‘Would you like to open the cloned repository?' popup appears.

:::::::::::::::::::::::::::::::::::::::::

Expand All @@ -126,7 +126,7 @@ So next, let's look at editing code.

::::::::::::::::::::::::::::::::::::: keypoints

- Key VSCode features are accessible via the left navigation bar and the menu.
- Key VSCode features are accessible via the left navigation bar and the menu
- VSCode's capabilities can be increased by installing extensions
- Language-specific support is available via extensions
- A VSCode "workspace" is a project that consists of a collection of folder and files
Expand Down
2 changes: 1 addition & 1 deletion episodes/13-code-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ But in essence, the code is designed to do the following:
1. Open a file in the CSV (comma separated value) format
1. Go through the file line by line, and:
- If the line begins with a `#` symbol, ignore it.
- Otherwise, extract the fourth column (which is in Fahrenheit), convert it to Celsius and Kelvin, and output those readings.
- Otherwise, extract the fourth column (which contains temperature in Fahrenheit), convert it to Celsius and Kelvin, and output those readings.

Let's take a look at some of what the code editor gives us.

Expand Down
8 changes: 5 additions & 3 deletions episodes/14-running-debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ exercises: 0

## Running Python in VSCode

Now let's try running a Python file.
First, make sure your Python doesn't have any errors!
Now let's try running a Python script.
First, make sure your Python code doesn't have any errors!
Then, select the "Play"-looking icon at the top right of the code editor.

FIXME: screenshot snippet of the play icon?
Expand Down Expand Up @@ -147,7 +147,9 @@ FIXME: show screenshot snippet of debugging icons
- The first one is continue, which allows the script to keep running until the next breakpoint.
- The next one allows us to step over - or through - the script one statement at a time.
- The next two allow us to choose to step into or out of a function call, which is interesting.

If we want to examine the inner workings of a function during this debug session, we can do that.

- The green cycle one is to restart the debug process.
- The red cross stops debugging completely.

Expand All @@ -159,7 +161,7 @@ If we step again, and then again, our program halts because it's run into the pr

This tells us something useful - that the problem occurs in the first iteration of the loop.
So, this implies, the problem might be with the first line of data being processed,
since the Python is going through the data file line by line.
since the Python code is going through the data file line by line.
If we re-run the debugger, we can go through this process again.
And we can see something interesting when we get to the `if` statement.
From the code, we know that the if statement is looking for an exclamation mark at the beginning of the line to indicate a comment.
Expand Down
Loading