Python for Psychological Inquiry
A Problem-Solving Approach to Programming
A Note from the Course Designer
This course is built on a single conviction: programming is not primarily about syntax. It is about learning to think.
You have already studied statistics and written code in R. You understand what a variable is, what a distribution looks like, and what it means for a result to be significant. What this course asks is something different — not what the formula is, but why it exists. Not how to call a function, but what problem that function was designed to solve.
Python is chosen as the vehicle for this journey because it is versatile, readable, and widely used in psychological research, data science, and beyond. But Python is never the destination. The destination is a way of approaching problems: breaking them into pieces, representing information clearly, testing ideas systematically, and communicating findings honestly.
This course deliberately connects every new programming concept back to questions you already care about — questions about human behaviour, about measurement, about what data can and cannot tell us.
Because Advanced Statistics runs concurrently, this course is coordinated to amplify rather than duplicate that content. You will frequently find that something you are exploring in statistics — a t-test, a correlation, a distribution — appears here not as a formula to apply but as a problem to model.Rationale
Second-year psychology students bring a distinctive academic profile: they have been introduced to inferential thinking through statistics, they have experience writing structured code in R, and they are beginning to ask genuine research questions about human behaviour. This course is designed for precisely this moment.
Rather than treating Python as a new tool to be added to a toolkit, this course frames it as a lens through which to examine familiar ideas more carefully. When students learn to represent a distribution as a list of numbers and write code to compute its mean, they are not just learning Python — they are revisiting the concept of a mean and discovering what it is made of.
The course does not assume that students will become programmers. It assumes that they will become researchers and practitioners who work with data, who need to evaluate computational claims, and who benefit from understanding how the tools they use actually work.
Structure at a Glance
| Unit | Title | Central Question | Hours |
|---|---|---|---|
| Unit 1 | The philosophy of computing | How does a computer understand what I mean? | 6 hours |
| Unit 2 | Understand and manipulate data structures | How do I represent and explore what I have collected? | 6 hours |
| Unit 3 | Identifying patterns and evidence in data | How do I find signal within noise? | 8 hours |
| Unit 4 | Responsible communication with programming | How do I tell a story that is honest and clear? | 6 hours |
Course Outcomes
By the end of this course, students will be able to:
Decompose a psychological or behavioural research question into discrete, programmable steps, demonstrating understanding of how problems are structured before code is written.
Write, read, and debug Python code at a level sufficient to perform data loading, cleaning, exploration, basic analysis, and visualisation, without reliance on a single library's 'magic' functions.
Select and justify appropriate data structures (lists, dictionaries, dataframes) to represent psychological datasets, and explain how choice of representation affects what operations are possible.
Identify sources of error, bias, and misrepresentation in code-generated analyses and visualisations, and apply ethical data-reporting practices consistent with psychological research standards.
Learning Objectives by Unit
Each objective is assessable and maps directly to the course outcomes above. Objectives use Bloom's Taxonomy action verbs to indicate the level of cognitive engagement expected.
Unit 1 — The philosophy of computing
Theme: The relationship between human intention and machine execution- Define what an algorithm is and construct a plain-language algorithm for a familiar psychological task.
- Distinguish between Python syntax, logic errors, and semantic errors, and use error messages productively.
- Assign and manipulate variables using Python's core data types and relate each type to kinds of data encountered in psychology.
- Use conditional statements to model decision-making scenarios analogous to those in diagnostic or classification tasks.
- Construct and traverse loops to automate repetitive computations over collections of data.
- Write and call simple functions, explaining the concepts of input, output, and encapsulation in plain language.
- Compare the experience of writing Python with their prior experience in R, articulating what is similar, what is different, and why.
Unit 2 — Understand and manipulate data structures
Theme: Representing, cleaning, and understanding real data before analysis begins- Load a dataset from a CSV file using pandas and inspect its structure (shape, column types, missing values) before performing any analysis.
- Choose between lists, tuples, dictionaries, and DataFrames for a given representation task and justify the choice.
- Identify and handle missing data using appropriate strategies with awareness of the psychological and ethical implications of each choice.
- Compute descriptive statistics from scratch using base Python, then verify results using library functions — understanding the difference between implementation and invocation.
- Produce and interpret frequency tables and grouped summaries for both nominal and continuous data.
- Explain what it means for data to be 'tidy' and restructure a messy dataset into a tidy format.
- Distinguish between levels of measurement in a dataset and explain why this distinction affects which operations are meaningful.
Unit 3 — Identifying patterns and evidence in data
Theme: Using Python to probe hypotheses and understand relationships- Simulate a sampling distribution using loops and random number generation, and use this to build intuition for the concept of a p-value without formula-first reasoning.
- Implement a t-test computation step by step and interpret the output in the context of a psychological hypothesis.
- Compute Pearson's and Spearman's correlation coefficients and explain when each is appropriate.
- Visualise the relationship between two variables and read the output critically rather than accepting it at face value.
- Articulate the distinction between correlation and causation with reference to a specific dataset, identifying potential confounds.
- Describe what a simple linear regression equation represents, implement it manually, and interpret the slope and intercept in psychological terms.
- Produce a chi-square contingency analysis for categorical data and link it to the concept of independence.
Unit 4 — Responsible communication with programming
Theme: Writing code that is readable, reproducible, and honest- Write a fully commented and documented analysis script that a peer could run independently on a fresh machine.
- Design visualisations that accurately represent data, identifying and correcting common misleading choices.
- Apply a consistent and principled workflow to a novel dataset: load, inspect, clean, describe, analyse, visualise, interpret.
- Discuss the ethical responsibilities that arise when presenting computational results, including transparency about analytical decisions and limitations.
- Produce a brief written interpretation of a Python-generated analysis accessible to an audience without programming knowledge.
- Reflect on the course as a whole, articulating how computational thinking has changed or deepened their understanding of at least one concept from their statistics curriculum.