Class 3 — Builder → Coder

Part I
Open PsychoPy’s Coder view for the first time to read the Python that Builder has been generating for you all along, make some small, safe edits directly in code, and write a short script of your own from scratch.
Published

September 22, 2026

Every time you’ve clicked “Run” in Builder, PsychoPy has quietly written a Python script behind the scenes. Today you finally open it. Most of class is spent reading that generated code, not writing new code — you’ll go on a guided scavenger hunt through a Builder-generated script, finding the trial loop and the conditional that scores a correct response, and make some small edits directly in Coder. Then the closing exercise flips that: you’ll build a short, original Python script of your own, completely from scratch.

Reading due: Think Python ch. 5, 7 · Due the night before (Mon 9/21, 11:59 PM): HW1

What you’ll be able to do

  1. Trace how an if/elif/else conditional decides between two outcomes, and how a for loop repeats a block of code, reinforced through a Colab warm-up.
  2. Open PsychoPy’s Coder view on an existing Builder-generated experiment and locate the auto-generated .py file.
  3. Identify the for loop in the generated script that corresponds to the trial loop you built visually in Builder, and connect it back to the conditions spreadsheet from Class 2.
  4. Identify at least one if statement in the generated code (e.g., the correct-answer check) and explain what condition it’s testing.
  5. Make some small, non-breaking edits directly in Coder (e.g., change the instructions screen’s hardcoded text color) and confirm the experiment still runs.
  6. Write a short, original Python script — a list of stimuli, a for loop, input(), and an if/else check — from scratch in Coder, applying the same patterns practiced in today’s warm-up to a new task.
Back to top