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 | From Instructions to Ideas | How does a computer understand what I mean? | 5 hrs / 5 sessions |
| Unit 2 | Data Has Shape | How do I represent and explore what I have collected? | 5 hrs / 5 sessions |
| Unit 3 | Patterns and Evidence | How do I find signal within noise? | 5 hrs / 5 sessions |
| Unit 4 | Communicating with Code | How do I tell a story that is honest and clear? | 5 hrs / 5 sessions |
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.
Implement, from first principles, descriptive statistics and at least two inferential procedures covered in the concurrent statistics course, interpreting outputs as a psychologist rather than merely as a programmer.
Identify sources of error, bias, and misrepresentation in code-generated analyses and visualisations, and apply ethical data-reporting practices consistent with psychological research standards.
Produce a documented, reproducible analysis script and accompanying written interpretation that could be understood and re-run by a colleague unfamiliar with the original dataset.
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 — From Instructions to Ideas
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 — Data Has Shape
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 — Patterns and Evidence
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 — Communicating with Code
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.
This unit begins not with Python, but with a question: what does it actually mean to give instructions? Students discover that programming is a discipline of precision and that the challenge of writing code for a computer mirrors, in an illuminating way, the challenge of writing methods sections for psychology experiments.
What Is an Algorithm? Thinking Before Typing
▾The session opens without a computer. Students are given a psychology scenario — scoring a questionnaire — and asked to write out, in plain English, the complete set of steps needed to go from raw responses to a final score. Groups compare their versions and discover where ambiguity crept in.
Topics Covered
- Definition and properties of an algorithm: unambiguous, finite, correct
- The gap between human intention and machine instruction
- Why computers need precision that humans take for granted
- Introduction to the Python environment: Jupyter Notebooks or IDLE
- Writing and running a first Python statement; understanding the REPL
Classroom Activity
- Unplugged activity: groups write the algorithm for "compute the average Likert score from 10 responses, excluding any blank items"
- Groups compare algorithms; instructor facilitates discussion of where they differ and what each difference implies
- Live demo: show how Python executes each instruction one at a time
Variables, Types, and the Psychology of Categories
▾Variables are introduced not as 'boxes that store things' but as names we give to things so we can refer to them later. The four core data types are mapped directly onto students' existing knowledge of levels of measurement and data types from R.
Topics Covered
- Variables: assignment, naming conventions, reassignment
- Integers and floats: when precision matters (age vs. reaction time in milliseconds)
- Strings: representing names, categories, and text responses
- Booleans: true/false as the basis of all decision-making
type()and simple type conversion- Connecting Python types to levels of measurement: nominal (str), ordinal (int), interval/ratio (float)
Classroom Activity
- Students are given a printed dataset card (5 participants, each with age, gender, anxiety_score, above_threshold) and decide which Python type to use for each variable
- Live coding: building the dataset as individual variables, then discussing why this approach becomes unworkable at 500 participants
Decisions and Conditions: The If-Then Logic of Classification
▾Conditional logic is presented as the computational version of diagnostic reasoning. Students build increasingly complex classifiers, encountering the concepts of mutual exclusivity and exhaustiveness along the way.
Topics Covered
if,elif,else: structure and indentation- Comparison operators:
==,!=,<,>,<=,>= - Logical operators:
and,or,not - Nesting conditions vs. chaining
elif - The concept of a decision boundary and its arbitrariness
Classroom Activity
- Students implement the PHQ-9 scoring rubric as a Python function returning a severity category (minimal, mild, moderate, moderately severe, severe)
- Extension: add validation logic — what should the function return if the score is negative, or greater than 27?
Repetition and Loops: Automation as a Research Tool
▾Loops are introduced as the answer to the question: "What if I need to do this for every participant?" Students see that automation is not laziness — it is reproducibility.
Topics Covered
forloops over lists and ranges- Accumulators: building a running total or a collection
whileloops: iterating until a condition changesbreakandcontinue: controlling loop flowenumerate()for tracking position- Nested loops: brief introduction with a concrete example
Classroom Activity
- Given a list of 20 raw test scores, students write a
forloop to compute the total and mean without usingsum()orlen()— building these from scratch with an accumulator - Extension: loop over the scores again to flag any score more than 1.5 SDs from the mean
- Discussion: why two passes? Could this be done in one pass? What does this tell us about the structure of the computation?
Functions: Naming What You Mean
▾Functions are presented as a way of giving a name to a process — exactly as a researcher names a construct. Once defined, a function can be applied anywhere, ensuring consistency.
Topics Covered
defsyntax, parameters, andreturn- The difference between printing and returning
- Default parameter values
- Docstrings: documenting what a function does, not how
- Calling a function vs. defining it
- Brief preview of the Python Standard Library as 'functions other people wrote'
Classroom Activity
- Students refactor work from Sessions 1.2–1.4 into a small library of functions:
compute_mean(scores),compute_sd(scores),classify_severity(score),flag_outliers(scores, threshold) - Pair exercise: swap code with a partner. Can you understand what each function does from its name and docstring alone?
Unit 1 Session Summary
| Session | Topic | Key Activities | Deliverable |
|---|---|---|---|
| 1.1 | Algorithms & Python Environment | Unplugged algorithm design, REPL exploration | Written algorithm for a scoring task |
| 1.2 | Variables and Data Types | Dataset card exercise, live coding | Typed variable annotations for a dataset |
| 1.3 | Conditions and Classification | PHQ-9 classifier implementation | Working if/elif/else classifier |
| 1.4 | Loops and Automation | Score processing with accumulators | Mean and outlier-flagging script |
| 1.5 | Functions and Abstraction | Refactoring, peer code reading | Documented function library |
Before any analysis can be trusted, the data must be understood. This unit addresses a truth that is often glossed over in methods training: real datasets are messy, and the decisions made during cleaning are analytical decisions with consequences.
Collections: Lists, Dictionaries, and the Shape of Data
▾Students now confront the need to work with many values at once. This session introduces lists and dictionaries as the two fundamental collection types, and asks students to think carefully about which is the right choice for a given representation task.
Topics Covered
- Lists: ordered, indexed, mutable — for sequences of same-kind data
- List operations: append, remove, slicing, indexing, length
- Dictionaries: key-value pairs — for structured records
- Choosing between lists and dictionaries: a design decision, not a syntax question
- Lists of dictionaries as a natural model for a dataset of participants
- Tuples: briefly — when immutability matters
Classroom Activity
- Students receive a paper participant record and represent it first as a list, then as a dictionary. A second participant is added — discussion follows about which representation scales more naturally
- Guided coding: building a list of participant dictionaries and writing a loop to extract all ages
The Pandas DataFrame: Data as a Table
▾Pandas is introduced not as a library to be memorised but as a natural extension of what students just built. The session focuses on loading, inspecting, and understanding a dataset before touching it.
Topics Covered
import pandas as pd: the import statement and the alias conventionpd.read_csv(): loading real datadf.head(),df.tail(),df.shape,df.dtypes,df.info()- Accessing columns and rows:
df['column'],df.iloc[],df.loc[] - Basic filtering:
df[df['column'] > value] df.describe(): descriptive statistics at a glance — and why glance is not enough
Classroom Activity
- Students load a psychology dataset and answer a checklist of questions before performing any analysis: How many participants? What are the data types? Are there obvious outliers? Are there missing values?
- Discussion: what would happen if we skipped these steps and ran an analysis immediately?
Missing Data: The Values That Are Not There
▾Missing data is one of the most consequential and most neglected topics in quantitative psychology training. This session treats it as a conceptual problem first — why is data missing, and does it matter how it went missing?
Topics Covered
- What NaN means and how Python/pandas represents absence
- Three mechanisms of missingness: MCAR, MAR, MNAR
df.isnull(),df.isnull().sum(): quantifying missingness- Strategies: listwise deletion (
dropna), column removal, mean/median imputation - When each strategy is defensible — and when it is not
- Documenting what you did and why: the research audit trail
Classroom Activity
- Students compare two datasets: one with randomly missing data, one with data missing only for highest-anxiety participants. Could you tell the difference by looking at the NaN pattern alone?
- Apply three different missingness strategies to the same dataset and compare descriptive statistics across the three resulting versions
Descriptive Statistics from Scratch and from Libraries
▾This session revisits descriptive statistics — mean, median, mode, variance, standard deviation — and builds them from scratch in Python before using the library versions. The goal is not to memorise formulas but to understand what each statistic is actually doing to the data.
Topics Covered
- Computing mean, median, and mode from a list using only base Python
- Computing variance and standard deviation step by step: understanding the sum of squared deviations
sorted()for median; mode as the most common value- Verifying results with numpy and pandas
- Population vs. sample standard deviation (
ddof=0vsddof=1) - Percentiles and quartiles: what they tell us that the mean does not
Classroom Activity
- Paired task: one student writes
compute_variance(data, population=True), their partner writescompute_variance(data, population=False). They compare outputs and discuss when each is appropriate — reconnecting to the parameter vs. statistic distinction from the concurrent statistics course - Visual exploration: scatter plot of raw scores with a horizontal mean line and shaded SD region
Visualisation as Understanding, Not Decoration
▾Visualisation is introduced not as the last step in analysis but as an exploratory tool. Students produce histograms, box plots, and bar charts, spending significant time discussing what each plot reveals that a table of numbers does not — and what each conceals.
Topics Covered
- The matplotlib anatomy: figure, axes, plot elements
- Histogram: choosing bin width and what that choice implies
- Box plot: five-number summary as a visual, interpreting whiskers and outliers
- Bar chart for categorical data: frequency vs. proportion
- Overlaying plots: comparing two distributions visually
- Titles, labels, legends: what every plot must communicate
Classroom Activity
- Students generate three visualisations of the same variable: narrow-bin histogram, wide-bin histogram, and box plot — then write a short reflection on what each emphasises and what it obscures
- Group critique: pairs swap plots and give feedback on whether the visualisation would be clear to a first-time reader
Unit 2 Session Summary
| Session | Topic | Key Activities | Deliverable |
|---|---|---|---|
| 2.1 | Lists and Dictionaries | Paper participant records, list vs dict comparison | Participant collection in both formats |
| 2.2 | Pandas DataFrames | Dataset inspection checklist exercise | Pre-analysis inspection report |
| 2.3 | Missing Data | MCAR vs MNAR comparison activity | Missingness strategy comparison table |
| 2.4 | Descriptive Statistics | From-scratch implementation, library verification | compute_variance() function with both modes |
| 2.5 | Visualisation | Three-plot reflection, peer critique | Annotated plot set with written reflection |
This unit is where Python becomes a thinking tool rather than just a computing tool. Students use their conceptual vocabulary to investigate relationships and test ideas. The parallel statistics course is running live during this unit, so students will often encounter the same concept from two directions in the same week. This is intentional.
Probability and Simulation: Building Intuition for the p-Value
▾Before any hypothesis test is coded, this session uses simulation to build intuition for what a p-value actually represents. Students generate data under a null hypothesis thousands of times and observe how often they see a result as extreme as their observed one.
Topics Covered
- Random number generation:
random.random(),random.choice(),random.gauss() - Simulating coin flips, dice rolls, and then simulated experiments
- The sampling distribution as an empirical object, not just a theoretical one
- Counting how many simulations exceed an observed value: an intuitive p-value
- Why 5,000 simulations give a different answer from 50
- Connecting the simulation result to the formal p-value and alpha concepts
Classroom Activity
- Students simulate: "If sleep quality has no effect on memory test scores (null hypothesis), how often would we see a difference as large as 8 points by chance?" They count the proportion of simulated differences ≥ 8 and compare to alpha = 0.05
- Discussion: what changes if we set alpha to 0.01? What changes if our sample was larger?
The t-Test: A Case Study in Implementing an Inferential Test
▾Rather than simply calling scipy.stats.ttest_ind(), students implement an independent samples t-test step by step. The library function is used at the end — for verification, not as the primary tool.
Topics Covered
- Revisiting the hypothesis structure: null, alternate, one-tailed, two-tailed
- The logic of the t-statistic: how different are the means, relative to how different we would expect by chance?
- Step-by-step implementation: group means, group variances, pooled standard error, t-statistic
- Degrees of freedom: what they count and why they matter
- Verifying the manual result with
scipy.stats.ttest_ind() - Effect size: why statistical significance is not the same as practical significance
Classroom Activity
- Guided worksheet takes students through each step of the t-test computation; at each step they are asked: what would this number tell us if we stopped here?
- Reflection: the library function returns the same numbers in one line. What do we lose by only ever using the library?
Correlation: Measuring the Direction and Strength of Relationships
▾Correlation is presented as a question about geometry as much as statistics: do these two variables move together? The session builds Pearson's r from its components before computing it with a library. Spearman's rho is introduced as what happens when we care about rank rather than magnitude.
Topics Covered
- Covariance: the numerator of Pearson's r and what it captures
- Why r is bounded between -1 and +1: the normalising role of standard deviations
- Computing Pearson's r step by step, then with
numpy.corrcoef() - Spearman's rho: computing ranks with
scipy.stats.rankdata(), then correlating the ranks - When to use each: normality, outliers, and whether rank or magnitude is meaningful
- The correlation matrix: representing many relationships at once
Classroom Activity
- Students compute both Pearson's r and Spearman's rho for the same two variables in a dataset containing strong outliers, then discuss: which better represents the true relationship?
- Scatter plot with correlation coefficient annotated: students produce this for three pairs of variables and rank them by strength, then discuss whether strong correlation implies importance
Correlation, Causation, and Confounds: Critical Thinking with Code
▾This session slows down to think about what a correlation coefficient actually means in the real world. Using datasets where strong correlations are artefacts of confounding variables, students practise the critical evaluation skills that separate a researcher from someone who runs functions on data.
Topics Covered
- Classic spurious correlations and the third-variable problem
- The concept of a confounding variable: what is the third thing?
- Partial correlation: holding a third variable constant — conceptual introduction
- Directionality: when A correlates with B, could B cause A?
- The ecological fallacy: correlations at the group level may not apply to individuals
- Implications for psychological research: media misinterpretation of correlation findings
Classroom Activity
- Students identify a plausible confound in a dataset with a strong correlation, subset the data by that confound, and compute the correlation separately within each subset
- Writing exercise: write a single paragraph a journalist might write about the finding, then a corrected version written by a researcher
Introduction to Regression and Chi-Square: Prediction and Independence
▾Simple linear regression as a natural extension of correlation — moving from describing a relationship to predicting a value — and chi-square as the tool for asking whether two categorical variables are related. Both are implemented at least partially from scratch.
Topics Covered
- From correlation to regression: the line of best fit as a predictive model
- The slope and intercept: what each means in the context of the variables
- Residuals: the difference between prediction and reality
- R-squared: what proportion of variance in Y is explained by X?
- Chi-square: testing whether the distribution of one categorical variable is independent of another
- Observed vs. expected frequencies; computing chi-square manually in Python
Classroom Activity
- Regression: students implement the OLS formula for slope and intercept manually, plot the resulting line over a scatter plot, then use sklearn to verify
- Chi-square: given a contingency table (gender × diagnosis), students compute expected frequencies and chi-square without scipy, then verify with it
Unit 3 Session Summary
| Session | Topic | Key Activities | Deliverable |
|---|---|---|---|
| 3.1 | Probability and Simulation | Null hypothesis simulation exercise | Simulation script with p-value estimate |
| 3.2 | The t-Test | Step-by-step guided implementation | Annotated t-test worksheet and script |
| 3.3 | Correlation | Pearson vs Spearman comparison, matrix | Correlation analysis with plots |
| 3.4 | Causation and Confounds | Confound identification, journalist vs researcher writing | Short critical evaluation paragraph |
| 3.5 | Regression and Chi-Square | OLS implementation, contingency table exercise | Manual and library outputs compared |
The final unit asks: now that you can compute things, can you communicate them honestly? This unit addresses reproducibility, visualisation ethics, writing for non-technical audiences, and the skills of reflection and synthesis. The capstone project draws on everything from the preceding three units.
Reproducibility: Writing Code That Others Can Run
▾Students discover how quickly an undocumented script becomes opaque — even to its own author — and learn the practices that make code a reproducible scientific artifact.
Topics Covered
- Code comments: when to comment and what not to comment
- Docstrings: documenting functions for others
- Variable naming as documentation: why
score_before_training>s1 - The analysis pipeline as a sequence: import, inspect, clean, describe, analyse, visualise, interpret
- Jupyter Notebooks as a format for literate programming
- Setting a random seed for reproducibility in simulations
- The replication crisis in psychology: a brief contextual discussion
Classroom Activity
- Students receive a deliberately poorly documented script that performs a correct analysis. They reconstruct what it does, add appropriate comments and docstrings, rename variables, and reorganise it — without changing any analytical logic
- Pair exercise: one student runs the partner's refactored script and records every point of confusion. These confusions become the agenda for a short revision
Visualisation Ethics: Honesty in Charts
▾Students build problematic visualisations deliberately, understand why they mislead, and then correct them. The goal is critical literacy as much as technical skill.
Topics Covered
- Truncated y-axes: making small differences look large
- Cherry-picking time windows in a time-series plot
- Inappropriate chart types: 3D pie charts, dual-axis plots with arbitrary scales
- Missing error bars or confidence intervals
- Colour choices that mislead: gradients implying order where there is none
- APA and ethical reporting standards for figures
Classroom Activity
- 'Spot the Manipulation': students are shown six published-style charts containing at least one misleading choice each, and must identify the problem and suggest a correction
- Fix it: students recreate two of these charts correctly in Python, writing a one-sentence APA-style caption for each
Writing for Two Audiences: Researchers and Non-Researchers
▾Students take a Python-generated analysis and write two interpretations of the same result: one for a peer reviewer, and one for a general reader. The exercise reveals how much translation is required and what is lost or gained in each version.
Topics Covered
- What a results section should contain: statistic, df, p-value, effect size, direction
- Translating statistical language for non-specialist audiences
- Common misinterpretations: what a p-value is not, what 'no significant difference' does not mean
- Reporting limitations: what the analysis cannot tell us
- Connecting to ethical data reporting standards from the R programming course
Classroom Activity
- Given output of a correlation analysis (r = 0.43, p = 0.02, n = 36), students write: (a) a formal APA-style results paragraph, and (b) a three-sentence plain-language explanation for a school newsletter
- Pairs read each other's versions and discuss where the technical version is inaccessible and where the plain-language version has been oversimplified
End-to-End Pipeline: Applying the Full Workflow
▾A supervised capstone exercise. Students receive a dataset they have not seen before and a brief research question, and must apply the complete analytical pipeline working individually or in pairs.
Pipeline Steps
- Load and inspect the dataset: shape, types, missing values
- Clean: address issues found in step 1; document all decisions
- Describe: compute and display relevant descriptive statistics
- Visualise the distributions of key variables
- Formulate and test a hypothesis appropriate to the research question
- Visualise the relationship of interest
- Interpret: what does the analysis suggest? What can it not tell us?
- Reflect: what would you do differently with more time or more data?
Reflection and the Bigger Picture
▾The final session steps back from code entirely. Students present their pipeline exercise briefly, share one thing that surprised them, and engage in a structured reflection on how computational thinking has changed how they think about statistics, measurement, and research.
Structure of the Session
- Brief presentations: each student or pair shares one visualisation and one finding from Session 4.4 (20 minutes total)
- Structured written reflection responding to the prompts below
- Whole-group discussion: what concepts from statistics do you now understand differently?
- Looking ahead: brief introduction to what Python can do that this course has not covered — NLP, web scraping, machine learning — as motivation for continued learning
- Describe one concept from your statistics course that you now understand differently because of writing code to implement it.
- Describe a moment in this course when you were confused. What were you confused about? How did you resolve it?
- If you were to explain to a friend what 'computational thinking' means, what would you say?
- What is one thing you wish you had been told at the start of this course?
- What is one question about data or programming that this course has left you wanting to explore?
Unit 4 Session Summary
| Session | Topic | Key Activities | Deliverable |
|---|---|---|---|
| 4.1 | Reproducibility | Refactoring undocumented script, peer confusion audit | Fully documented and reorganised script |
| 4.2 | Visualisation Ethics | Spot the manipulation, fix-it exercise | Two corrected charts with APA captions |
| 4.3 | Two Audiences | Dual-audience writing exercise | APA paragraph and plain-language version |
| 4.4 | End-to-End Pipeline | Supervised novel dataset analysis | Complete documented analysis notebook |
| 4.5 | Reflection and Discussion | Mini-presentations, guided reflection | Written reflection (300–400 words) |
Assessment Framework
Assessment is continuous and process-oriented. The objective is not to test whether students can produce a correct output under examination conditions, but whether they have developed the habits of thinking that will serve them in research and practice. There is no final written examination.
| Component | Description | Weight | CO Mapped |
|---|---|---|---|
| Unit 1 — Function Library | Documented set of functions from Sessions 1.2–1.5 | 15% | CO1CO2 |
| Unit 2 — Data Inspection Report | Pre-analysis report on an assigned dataset | 20% | CO2CO3 |
| Unit 3 — Annotated Analysis | Step-by-step commented inferential analysis | 25% | CO4CO5 |
| Unit 4 — Pipeline Notebook | End-to-end analysis on an unseen dataset | 25% | CO5CO6 |
| Reflection Essay | 300–400 words responding to the Session 4.5 prompts | 15% | CO1CO6 |
A Note on Grading Code
When evaluating submitted scripts and notebooks, priority is given in the following order:
- Correctness of thinking: does the student's approach demonstrate understanding of what they are trying to compute and why?
- Clarity and documentation: can the reader follow the logic without running the code?
- Correctness of output: does the code produce the right answer?
- Elegance and efficiency: is the code concise without sacrificing clarity?
Resources and Tools
Software
- Python 3.10+ — freely available from python.org
- Anaconda distribution — recommended; includes Jupyter, pandas, numpy, matplotlib, scipy, and seaborn in a single installation
- Jupyter Notebooks — for literate programming sessions and submitted assessments
- Visual Studio Code with the Python extension — optional alternative for students comfortable with an IDE
Datasets
- Open Psychometrics (openpsychometrics.org) — freely available psychology survey datasets
- UCI Machine Learning Repository — well-documented datasets suitable for teaching
- Synthetic datasets generated by the instructor, drawn from realistic psychological measurement scenarios
Reference Reading
- Think Python, 2nd Ed. (Downey, 2015) — available free online; focused on computational thinking
- Python for Data Analysis (McKinney, 2022) — authoritative reference for pandas
- Telling Stories with Data (Alexander, 2023) — addresses reproducible research and ethical reporting
- How Charts Lie (Cairo, 2019) — essential reading for Session 4.2
Concurrent Course Coordination
The following topics are designed to appear in both courses within the same two-week window:
- Hypothesis testing framework — Unit 3, Sessions 3.1 and 3.2
- t-Tests (paired and independent) — Session 3.2
- Pearson's and Spearman's correlation — Session 3.3
- Introduction to regression — Session 3.5
- Chi-Square — Session 3.5
Instructor Notes
Managing the Transition from R
The most common early frustration is syntactic: "In R I just did this one thing, why is Python different?" The recommended response is not to say "Python is better" or "R is better" but to ask: "What problem were you solving in R, and how does Python ask you to solve it?" This orients students toward the underlying concept rather than the surface syntax.
Supporting Students Who Struggle with Abstraction
Functions — particularly the distinction between defining and calling, and between parameters and arguments — are a common sticking point. The best intervention is a concrete analogy: a recipe is a function definition; following the recipe for a specific set of ingredients is calling it. The recipe does not cook anything on its own.
Students who find abstraction difficult often excel at concrete activities. Extended practice with small functions that do one thing is more effective than explanation.
Handling the Concurrent Statistics Pressure
Students are simultaneously learning inferential statistics formally and encountering it computationally. There will be weeks when the statistics course is demanding and students arrive intellectually stretched. On those weeks, reduce the pace and privilege consolidation over progression. Sessions 3.3 (correlation) and 3.5 (regression and chi-square) are most suitable for slowing down.
Ethical Discussions
Several sessions include ethical touchpoints. These are not interruptions to the technical content — they are part of it. The goal is to make students uncomfortable with the idea that analysis can be ethically neutral. The instructor's role is to ask questions, not to provide correct answers.
Assessment Feedback
Feedback on submitted work should be specific about reasoning, not just output. "Your function returns the correct mean" is less useful than "Your function correctly computes the sum and divides by length, but note that len() returns an integer — in what situation could this cause a problem?" The latter teaches students to anticipate edge cases, which is a core programming skill.