Skip to content

Lab Exercise 1 Python

Hanyuan Li edited this page Jun 4, 2026 · 5 revisions

Run from VS Code

If you have the Jupyter extension installed, then you can run your code in one of three ways:

  1. Running the current cell
  2. Running the current cell, and all cells below it
  3. Running all cells

The output for each code cell is directly underneath, and all variables from previous code blocks, if evaluated, can be used in future code blocks as if everything was one large Python file with intermediate outputs.

Run using web browser

To open and run the GraphTraversal.ipynb notebook, follow these steps:

  1. Launch Jupyter Notebook
    Open a terminal and navigate to the Lab-Exercise-1/Python directory. Then run:

    jupyter notebook

    If you are running in Docker, use this command instead:

    jupyter notebook --allow-root --ip=0.0.0.0

    This will launch Jupyter in your default web browser.

    You should see output similar to the image below in your terminal:

    Click on one of the provided URLs or files to access the Jupyter interface.

  2. Open the Notebook
    After clicking the URL, you will see an interface similar to the one shown below:

    Navigate to and click on GraphTraversal.ipynb to open the notebook.

  3. Run Cells
    After opening GraphTraversal.ipynb, scroll down to find the code cells. You should see something similar to the image below:
    To execute a code cell, either click on it and press Shift + Enter, or click the "Run" button in the toolbar at the top.

  4. Edit & Experiment
    You can freely modify the code cells to experiment with different inputs or graph structures.

If Jupyter is not installed, you can install it via pip:

pip install notebook

More information about Python

Clone this wiki locally