Chalmers Advanced Python

Exercise 01: Getting started

Advanced Python Course
Chalmers DAT690 / DIT516 / DAT516
2026

by John J. Camilleri & Muhammad Mustafa Hassan

Purpose

The purpose of this lab is to get you up and running with everything you need to start working on Labs 1–3. This exercise targets learning objectives:

1. Python development environment

Firstly, it is essential that you have a working Python installation on your computer, together with a text editor or IDE such as VS Code. You also need to have some familiarity with your computer’s terminal/shell.

Hopefully you already have these from a previous course. Note that web-based solutions like the Self Practice tool or Jupyter Notebook will not be enough.

Before progressing to the next step, ensure that you can:

  1. Create, edit and save a “hello world” Python file on your computer with filename hello.py.
  2. Run this Python file from your IDE, e.g. by clicking the ▶ button in VS Code.
  3. Run this Python file from your terminal, e.g. by running python3 hello.py

2. Virtual environments

In this course we are going to be installing and using external Python libraries. In order to be able to do this, you need to be familiar with how to set up virtual environments.

The general idea is that each project has its own virtual environment into which packages are installed. See the instructions in the lecture notes here: Packages and virtual environments

Before progressing to the next step, ensure that you can:

  1. Create a Python virtual environment and activate it
  2. Install the external library rich into your virtual environment with pip install rich
  3. Import this library in your own code and use it, e.g. with this code snippet:

     from rich import print
     print("Hello, [bold green]World[/bold green]!", ":snake:")
    

3. Git

The Git version control tool will be used throughout this course for:

It is therefore important to get the hang of Git early on. To complete this step, do the following:

  1. Familiarise yourself with Git by reading the walkthrough in the lecture notes: Introduction to Git
  2. Set up an SSH key and ensure you have Git installed: Setting up SSH and Git
  3. Access Chalmers GitLab as described here: Working with Chalmers GitLab
  4. Try out creating a repository and pushing to it:
    1. Create a new repository in GitLab: https://git.chalmers.se/projects/new#blank_project
    2. Clone the repository locally, using git clone ... on the command line or directly inside of VS Code.
    3. Add the Python files created above to the repository, commit and push them.
    4. View your repository on GitLab and ensure that the new files appear there.
  5. Create a merge request:
    1. Create a new branch locally and check it out.
    2. Make some small changes to one of your Python files. In addition, add one new file to the repository.
    3. Commit these changes to the new branch and push them to GitLab.
    4. Create a merge request from this new branch into the main branch.
  6. Review the merge request:
    1. View the merge request in GitLab, examine the diff and leave a comment on the merge request.
    2. Push additional commits to the same branch, and see that the merge request is updated.
    3. Merge the merge request in GitLab.
  7. Locally, change back to main branch. Pull from GitLab and you should see the new changes have been updated.