Lab 0: Getting Started

  • Due: Wednesday 09/02 @ 11:59pm
  • Points: 1
  • Download: lab00.zip

This lab is required for all students.

Introduction

Complete this lab at home as soon as possible! If you want help, ask on Ed or come into office hours.

This lab explains how to set up your computer to complete assignments.

Here's an outline:

  • Setup: Install Python and Visual Studio Code.
  • Task A: Examples: Predict how Python behaves.
  • Task B: Implement a Function: Edit a file and run its tests.
  • Task C: Submit the Assignment: Create your submission and upload it.
  • Appendix: Useful Python Command Line Options: Commands that are useful in debugging your work, but not required to complete the lab. We include them because they are likely to be helpful to you throughout the course.

Setup

Install Python

Install Python using the official installer for your operating system. When choosing a version of Python, always choose one labeled stable that begins with a 3, such as 3.14.7. The larger the version number, the better. Version 3.11 or later will work for this course. (On Windows, the install manager described below chooses the latest version for you.)

Windows: Download the Python install manager from the Windows downloads page, open the downloaded file, and click Install. If it asks whether to add Python to your PATH, accept.

Mac: Download the macOS installer from the macOS downloads page, open the downloaded .pkg file, and follow the instructions of the installer.

Linux: Python is typically installed already.

Install Visual Studio Code

Install VS Code using the official installer for your operating system, which is available from the Visual Studio Code download page.

Windows: Download the Windows x64 User Installer and run it.

Mac: Download the Mac archive, open the downloaded file, and drag the Visual Studio Code application into your Applications folder.

Linux: Download the .deb or .rpm package for your distribution and install it using your package manager.

Important: When you first open VS Code, you will be asked to log in to use GitHub Copilot AI features. You can just close the login window. There's no need to log in to VS Code for this course.

Download and Open Lab00

Click the lab00.zip link at the top of this page. It will be placed in your Downloads folder. You can move the lab00.zip somewhere else on your computer for safe keeping.

We recommend creating a folder called cs61a contains nested folders called lab, hw, and proj. You can create this folder structure using your computer's file manager:

  • Mac: Open Finder and select Desktop in the sidebar. Choose File > New Folder and name it cs61a. Open the new folder, choose File > New Folder three times, and name the folders proj, lab, and hw.
  • Windows: Open File Explorer and select Desktop. Select New > Folder, name it cs61a, and press Enter. Open the new folder, select New > Folder three times, and name the folders proj, lab, and hw.
  • Linux: Open your file manager and select Desktop. Create a new folder using the file manager's New Folder option, name it cs61a, and open it. Create three more folders inside it named projects, lab, and hw.

Then, unzip it: on Mac or Linux, double-click the downloaded file; on Windows, right-click it and choose Extract All.... Unzipping creates a lab00 folder containing lab00.py and other files.

Important: Use VS Code to open the whole lab00 folder. Use Open Folder... in the File menu of VS Code, or press the Open... button that appears when you first start VS Code. You can also drag the lab00 folder onto an open VS Code window to open it (or onto the VS Code icon on the Mac dock or Windows desktop shortcut).

When you open an assignment folder, VS Code will offer to install the extensions recommended for the course. Accept the recommendations. These include:

  • Python language support from Microsoft
  • Provenance, which keeps a record of what you do in VS Code while working on a course assignment and stores it on your computer (so that you can submit it).
  • Preceptor, an AI tool that helps you complete assignments and asks you questions to verify your understanding of the solutions you write.

Both Provenance and Preceptor were created at Berkeley and are being used for the first time this semester. If you have questions or encounter problems regarding either one, please post on the pinned Ed post for the course.

Provenance is required, but doesn't transmit your data. It is up to you to submit the record it creates.

Preceptor is not required for labs, but highly recommended. Getting checked off, either by Preceptor or a memeber of the course staff, is required for homeworks and projects. Using Preceptor does send your solutions and conversations to a language model, and by using it you consent to share this information. Try it out, and if you don't like it, you can stop using it and have conversations with the course TAs and tutors instead.

Verify Your Setup

Once the lab00 folder is open in VS Code, you should see lab00 at the top of the window and a list of files on the left that includes lab00.py.

From the Terminal menu within VS Code, select New Terminal, which should open a terminal pane at the bottom of your lab00 VS Code window. A terminal is a text-based interface to your computer. It starts on the command line, where you can issue commands. Try typing two commands:

  • Type ls and you should see a list of the file and folder names within lab00, including lab00.py.
  • Then, type python3 on Mac/Linux or python on Windows.

Once you type python3 (or python on Windows) you should see some information about Python and then >>>, which is the Python prompt. Commands like ls and python3 won't work after >>>. Instead, you can type any Python expression and see its value. Type 2 + 2 after the >>> and you'll see 4.

Important: Once you're done evaluating Python expressions, type exit() to return to the terminal's command line, which is where you write commands. Type ls again to check that you're back on the command line where your terminal started.

What can go wrong?

  • Opening a folder that contains lab00 instead of opening the lab00 folder directly won't work: all of the course-specific configuration requires that you open the assignment folder itself in VS Code.

  • If you never see >>> after typing python3 or python, try py. If none of those work, repeat the Install Python step, then open a new terminal within VS Code and try again. On Windows, the first time you run python it may pause to download Python before showing >>>; that's normal.

Provenance Troubleshooting

If provenance is not recording (If you can't find "Provenance: Recording" on the bottom of your VSCode window), ensure that:

  1. You have the latest version of VScode installed (and if you recently did a clean install, x out of vscode and reopen the folder entirely).
  2. You have the latest version of provenance installed.
  3. You have the full lab00 folder open (and did not unzip improperly into lab00 and now have some directory ./lab00/lab00).
  4. When you downloaded the folder, if it prompted you about whether you trusted the folder, ensure you selected 'yes'. If not, it will have a gray bar at the top talking about restricted mode.
    • Sometimes on mac, some people have a quarantine issue where you only have read access in the download folder as well, so move it to desktop or a cs61a folder (or in general just check read-write and trust issues).
  5. You have any python version 3.11 or greater.

Complete This Assignment

Task A: Examples

Q1: What Would Python Do?

One component of lab assignments is to predict how the Python interpreter will behave. We call these questions "What Would Python Do?" (WWPD). The answers to these questions are locked: you unlock them by correctly predicting the output of each expression.

Enter the following in the VS Code terminal to begin this section:

python3 -m pytest -k python_basics --unlock
Unlocking Examples

>>> 2000
______
>>> 2000 + 26
______

You will be prompted to enter the output of various statements/expressions. You must enter them correctly to move on, but there is no penalty for incorrect answers.

Task B: Implement a Function

Click the lab00.py file in the file explorer on the left panel of your VS Code window. You'll see its contents, starting with the word def.

Important: Turn on Auto Save in the File menu of VS Code. Then, whenever you change a file, the contents will be saved. Students who don't turn this on run into trouble because Python doesn't test unsaved answers.

Q2: Twenty Twenty-Six

In lab00.py, you should see a function called twenty_twenty_six that has a blank return statement. That blank is the only part you should change. Replace it with an expression that evaluates to 2026. What's the most creative expression you can come up with?

def twenty_twenty_six():
    """Come up with the most creative expression that evaluates to 2026
    using only numbers and the +, *, and - operators (or ** and % if you'd like).

    >>> twenty_twenty_six()
    2026
    """
    return ______

Important: The best way to try things out is to run python3 -i lab00.py (or python -i lab00.py on Windows) in the terminal, then type expressions after the >>> to see their values. This opens an interactive Python section immediately after running the script, allowing you to run expressions which include any functions and variables you defined.

While you work, the Provenance extension keeps a record of your editing activity in the assignment folder. Check the status bar along the bottom of your VS Code window: it should show Provenance: recording. (If it doesn't, make sure the Provenance extension is installed and that you opened the lab00 folder itself in VS Code, as described in Setup above.)

Running Tests

Each assignment comes with tests that check your work. Use the terminal to test the function you just completed:

python3 -m pytest -k twenty_twenty_six

Now Preceptor should pop up (if you installed it). If your answer was wrong, it will offer to help you understand why. If your answer was right, it will ask you questions to verify your understanding of your own answer.

Important: Preceptor may be down on Thursday 8/27 and Friday 8/28. The EECS department servers are undergoing maintenance, so Preceptor might not respond or might not pop up at all or give error messages. That's OK! You can still complete the rest of this lab (including submitting it) without Preceptor.

Task C: Submit the Assignment

Now that you have completed your first assignment, it is time to turn it in. You can follow these next steps to submit your work and get points.

Create Your Submission Zip with Provenance

Your submission is a single zip file that contains your completed assignment files, the record of how you completed it (from Provenance), and a record of your Preceptor interviews. To create it:

  1. Open the VS Code command palette: press Shift+Command+P (Mac) or Ctrl+Shift+P (Windows/Linux).

  2. Type Prepare Submission Bundle and select Provenance: Prepare Submission Bundle. (If asked which assignment, pick the one containing lab00.)

  3. A sealed .zip file is saved inside your lab00 folder. Its name contains lab00-bundle followed by the date and time it was created. This zip is all you need to upload.

Submit to Gradescope

  1. Log in to Gradescope using your Berkeley email address. You'll be taken to your Dashboard as soon as you log in. (You should have already been added to Gradescope. If this is not the case, please make a private Ed post.)

  2. On your Dashboard, select this course. This will take you to the list of assignments in the course that you are able to submit.

  3. Click on the Lab 0 assignment to open it.

  4. Upload the .zip file that Provenance just created. That one file is all you need to submit: it already contains your code, so don't upload any other files. (Each time you run Prepare Submission Bundle you get another zip, so if there are several, upload the one with the most recent time in its name.)

  5. Next, wait a few minutes for the autograder to score your submission. If you are surprised by your score, make sure you submitted a lab00-bundle zip that Provenance created, and not the lab00.zip starter file you downloaded. Assignments can be resubmitted as many times as you would like before the deadline.

Your responses to WWPD questions are not submitted to Gradescope, and they do not need to be. Lab credit is based on the code writing questions.

Congratulations, you just submitted your first assignment!

Appendix: Useful Python Command Line Options

Using Python

Here are the most common ways to run Python on a file from the VS Code terminal. (The examples use lab00.py, but these commands work for any assignment.)

  1. Using no command-line options will run the code in the file you provide and return you to the command line. If your file just contains function definitions, you'll see no output unless there is a syntax error.

     python3 lab00.py
    
  2. -i: The -i option runs the code in the file you provide, then opens an interactive session (with a >>> prompt). You can then evaluate expressions such as calling functions you defined. To exit, type exit(). You can also use the keyboard shortcut Ctrl-D on Linux/Mac machines or Ctrl-Z Enter on Windows.

If you edit the Python file while running it interactively, you will need to exit and restart the interpreter in order for those changes to take effect.

Here's how we can run lab00.py interactively:

    python3 -i lab00.py

If the python3 command doesn't work, please try using python or py. You can switch all of the copy/paste commands on this page from python3 to python or py using the toggle at the top right.


Back to Top

Accessibility Nondiscrimination

Copyright ©2026, Regents of the University of California and respective authors.

This site is built following the Berkeley Class Site template, which is generously based on the Just the Class, and Just the Docs templates.

View all course offerings