Introduction to Python for Simple Behavioral Experimentation
Undergraduate course, 2.14.0.35, Golm, 15.10.2025 – 04.02.2026
This course introduces beginners to Python programming and the basics of creating simple behavioral experiments used in cognitive science, such as reaction time, decision-making, and memory tasks.
Contents
Course Description
Part 1: Intro to Python (8 weeks)
This first part introduces beginners to the fundamentals of Python programming. Students will learn core programming concepts and tools used for data handling and basic scripting.
Key Topics:
- Getting started with Python (syntax, variables, data types)
- Control structures (loops, conditionals, functions)
- Working with data (lists, dictionaries, NumPy, and pandas basics)
- Introduction to Psychopy
Outcome:
By the end of Part 1, students will be comfortable writing and running basic Python programs.
Part 2: Building Behavioral Experiments in Python (6 weeks)
This second part builds on the programming foundation and focuses on creating, running, and analyzing simple behavioral experiments. Students will learn to design experiments involving reaction time, decision-making, and memory.
Key Topics:
- Designing experiments using PsychoPy
- Programming reaction time and decision-making tasks
- Collecting and storing participant data
- Basic data analysis and visualization in Python
- Debugging
Outcome:
By the end of Part 2, students will be able to create and analyze their own behavioral experiments relevant to cognitive science research.
Weekly Schedule (Weeks 1-15)
Week | Date | Topic | PPTs | Notebooks | Helpful Links |
---|---|---|---|---|---|
1 | Oct 15 | Intro to Programming, Python, and Setup | Lecture 1 | Class_notebook | Installation Guide |
2 | Oct 22 | Variables, Data Types, Basic Operations | |||
3 | Oct 29 | Control Structures: Conditionals, Loops | |||
4 | Nov 5 | Functions | |||
5 | Nov 12 | Lists, Dictionaries | |||
6 | Nov 19 | File I/O, Data Handling | |||
7 | Nov 26 | Data Analysis, Visualization | |||
8 | Dec 3 | Intro to PsychoPy, Stimulus Presentation | |||
9 | Dec 10 | Behavioral Experiment Design Concepts | |||
10 | Dec 17 | Programming Experiments I | |||
11 | Jan 7 | Programming Experiments II | |||
12 | Jan 14 | Programming Experiments III | |||
13 | Jan 21 | Data Collection, Analysis | |||
14 | Jan 28 | Debugging, doubt session | |||
15 | Feb 4 | Project Presentations |
Course Textbooks
Main Text:
Cafiero, Clayton. An Introduction to Programming and Computer Science with Python, 2nd Edition, 2023–2025. | ISBN: 979-8-9887092-1-3
Additional Suggested Readings:
Bonaretti, Serena. Learn Python with Jupyter
Downey, Allen B. Think Python
Psychopy: Psychopy official website
Final Project
Goal: Create and run a behavioral experiment using Python and PsychoPy in a group of 2 people.
There is a popular List of Behavioral Experiments online. I will select a few from this list and share them with you to choose from.
A sheet will be circulated sometime after we introduce PsychoPy and behavioral experiments (around the end of November or the start of December). In this sheet, you can indicate your experiment along with your group.
You are also welcome to suggest experiments outside the provided list and discuss them. Please note that each group should select a different experiment.
Requirements
Group size: Each project should be completed in groups of two students.
Participant Data Collection: Collect and analyze data from approximately 8-10 participants.
Submission: Submit your complete & well-documented code, analysis files, and a brief write-up (as an extension of your presentation) explaining the problem statement, the experiment, the analysis, work distribution, etc., by the end of the day on February 1.
Deliver a Presentation following the guidelines - see Presentation Guidelines, and submit your presentations files.
Presentation Guidelines
During the final presentation, each group should deliver a 10-minute presentation (+ 2 minutes for Q&A) that includes the following sections atleast:
- Introduction
- Introduce the goal or research question your experiment addresses.
- Experiment Design and Demonstration
- Outline your experimental structure (tasks, stimuli, conditions, and responses).
- Explain how participants interact with the task.
- Describe any challenges faced or design decisions made during development.
- Run a short live demonstration of your experiment.
- Data and Analysis
- Present a summary of the data collected (e.g., reaction times, accuracy).
- Include simple visualizations (plots, tables) created with Python.
- Provide a brief interpretation of what the results indicate.
- Reflection
- Explain how you divided the tasks within the team and who contributed to which parts.
- Discuss what worked well, what was challenging, and what you learned.
- Suggest possible improvements or extensions for the future.
Final Presentation Date: February 4, 2026
Grading
The final project is assessed on a Pass/Fail basis. To pass, students must complete the Final Project and fulfill all the Requirements
LLM policy
Adapted from Prof. Mausam’s guidelines
It is acceptable to seek help from an LLM/Conversationsal Chat agents. But you cannot copy any piece of code or document from an LLM. For example, interact with an LLM to get intuition about the project, critique ideas, and brainstorm. Also, use LLM to learn syntax for a language, get help with debugging. But do NOT use it to write code that you copy/paste in for your final project. Instead, write your own code yourselves.
Office Hours
- Time: Wednesday 16:00–17:00 (by appointment)
- Location: bldg. 14, room 4.10, Golm