Fall 2026
  • Discord
  • Gradescope
  • Syllabus

On this page

  • Getting the code
  • The loop
  • Submitting

Lab: Doctests

Due: Wednesday, September 23 at 11:59pm (one week after it is assigned) Worth: 4 points

Starter code: github.com/rtealwitter/lab-doctests

This lab introduces the workflow used in later labs: complete a Python file until its doctests pass, push it to GitHub for preliminary feedback, and submit the repository on Gradescope for the authoritative test result. The starter repository contains lab.py, a file of about thirty short functions whose bodies are blank. Each one has a description and a set of doctests; your job is to write the body so that every doctest passes.

Each function should take about five minutes, for a total of roughly two hours. If you spend much longer than five minutes on one function, ask me, a classmate, or a QCL tutor for help.

A warning before you start. Every function in this lab can be solved instantly by an LLM like ChatGPT or Copilot. Write them yourself anyway. These problems build the fluency you will need for later work that an LLM cannot solve. If you cannot do these on your own now, you will not be able to do those later.

Getting the code

  1. Fork the starter repository, github.com/rtealwitter/lab-doctests, to your own GitHub account with the Fork button. You now have your own copy that you are allowed to push to.

  2. Clone your fork to your laptop and open the folder in VS Code:

    $ git clone https://github.com/<your-username>/lab-doctests
    $ cd lab-doctests

The loop

Open lab.py and work one function at a time. For each function, read its description and doctests, write the body, then run the doctests from your terminal:

$ python3 -m doctest lab.py

Silence means every test passed. While tests are still failing, the command prints each failing example with what it Expected and what it Got, so you always know exactly which function to fix next. Add -v if you want to see the passing tests tallied up too. Repeat this process until the command falls silent.

Submitting

Commit your work, then push it to GitHub:

$ git add lab.py
$ git commit -m 'complete lab.py'
$ git push

Your fork comes with a GitHub Actions workflow that runs the same doctests automatically every time you push. Enable Actions on your fork through its web interface, and after your next push you will see a tests badge turn from red to green once all doctests pass.

The action is preliminary feedback, not the grade. Once it passes, submit your GitHub repository and branch to the Gradescope Programming Assignment. Gradescope runs instructor-owned pytest cases, including inputs not shown in the doctests, and its result is authoritative. There is no partial credit, so fix, push, and resubmit until all Gradescope tests pass.