Work together with your group in breakout rooms to identify and fix the bugs in this codebase.
Choose one teammate to execute the following steps just once at the beginning of the activity:
-
Navigate to the folder where you wish to save activities. This could be your
projectsfolder, or you may want to create a new folder for all of your activities.If you followed Ada's recommended file system structure from the Intro to Dev Environment lesson in Learn, you can navigate to your projects folder with the following command:
$ cd ~/Developer/projects
Or, if you want to create a new folder for all of your activities:
$ cd ~/Developer $ mkdir activities $ cd activities
If you've already created an activities directory, you can navigate to it with the following command:
$ cd ~/Developer/activities
-
In Github click on the "Fork" button to fork the repository to your Github account. This will make a copy of the activity in your Github account.
-
"Clone" the activity into your working folder. This command makes a new folder named for the activity repository, and then puts the activity into this new folder.
$ git clone <clone_url_for_the_activity>
The
<>syntax indicates a placeholder. You should replace<clone_url_for_the_activity>with the actual URL you'd use to clone this repository. If you click the green "Code" button on the GitHub page for this repository, you'll see a URL that you can copy to your clipboard.Use
lsto confirm there's a new activity folder -
Move your location into this activity folder
$ cd errors-and-debugging -
Create a virtual environment named
venvfor this activity:$ python3 -m venv venv
-
Activate this environment:
$ source venv/bin/activateVerify that you're in a python3 virtual environment by running:
$ python --versionshould output a Python 3 version$ pip --versionshould output that it is working with Python 3
-
Install dependencies once at the beginning of this activity with
# Must be in activated virtual environment $ pip install -r requirements.txtNot all activities will have dependencies, but there will still be an included
requirements.txtfile.
Summary of one-time activity setup:
- Fork the activity repository
-
cdinto your working folder, such as yourprojectsoractivitiesfolder - Clone the activity onto your machine
-
cdinto the folder for the activity - Create the virtual environment
venv - Activate the virtual environment
venv - Install the dependencies with
pip
-
When working on this activity, ensure that your virtual environment is activated:
$ source venv/bin/activate -
If you want to work on another project from the same terminal window, you should deactivate the virtual environment when you are done working on this activity:
$ deactivate
The code in main.py invokes functions written in logical.py, runtime.py, and syntax.py. We'll run into bugs when we execute the code in main.py is executed.
-
Check that you are in the root of the project directory. If you are unsure if you are in the root of the directory, execute the command
pwdin the terminal. If you followed our suggested directory structure and are in the root of the project directory, the command should print out something like:~/Developer/activities/errors-and-debugging -
To execute the code in this repo, from the root of the project directory, execute this command in the terminal
python main.py -
Observe how Python reports the error in the stack trace. Make sure to work through the issues together using VS Code’s LiveShare or Zoom screen sharing!
-
Pay attention to
- File names
- Line numbers
- Error type
-
Before fixing each error:
- State what the error is
- Hypothesize the cause of the error
- Propose a fix
NOTE: DO NOT edit any of the functions that start with test_ in their names.
- Potential discussion questions:
- What have you tried in the past?
- What worked well for you?
- What strategies do you want more practice in?
- How do you plan to incorporate them?