Practical Programming for Psychologists 2023-24
School Of Human And Behavioural Sciences
Module - Semester 1
We will cover (at least) the following:
General elements of programming (exemplified in Visual Basic):
- Planning your program: What is the problem? How am I going to solve it? How can I break the solution down into steps?
- Variables and Data types: How to declare, use and manipulate numbers, strings, arrays, lists, and (VB) objects.
- Assigning values: How to give a variable a value.
- Scope of variables: local and global variables.
- Arithmetic operations: how to add, subtract, multiply etc
- Simple string manipulations, e.g., concatenation. How to handle and manipulate file names.
- Collections of data: Creating and processing Lists and Arrays.
- Subroutines and functions: What they are for, and the difference between them. Passing arguments to and returning values from functions.
- If... then ...else .. End if statements. How to make a conditional statement.
- Loops: doing something repeatedly: a. For ... Next loops: doing the thing some number of times b. Do Until ... Loop, Do While ... Loop: doing the thing until (or while) some condition is fulfilled.
- Basics of “Object-oriented” programming. Object hierarchies. Object.Method, Object.Property.
Visual interface programming
- Use of the VB programming environment,.
- Graphical user interface (GUI) design.
- Controls: what are they? Controls as objects.
- VB Forms, placing controls on forms, naming controls. Changing properties of controls.
- The object.method and object.property syntax.
- How to manipulate common VB controls: Command buttons, text boxes, list boxes, labels, frames, option (radio) buttons, check boxes, data tables, progress bars etc.
- Standard methods for the common controls. Linking controls to the underlying program.
- File input/output; reading data from a file. Using file dialogs to Open and Save files.
Visual Basic for Applications (VBA): Use in Excel
- Starting VBA in Excel: The programming interface
- Linking VBA to the Excel worksheet.
- The Excel object model: Workbooks, Worksheets, Ranges, Cells.
- VBA program modules, and the VBA UserForm.
- Programming data manipulation in Excel with VB.
-threshold - (C) Adequate answer to the question, largely based on lecture material. No real development of arguments.
-good - (B) Reasonably comprehensive coverage. Well organised and structured. Good understanding of the material.
-excellent - (A) Comprehensive and accurate coverage of the area clarity of argument and expression. Depth of insight into theoretical issues
- Students will gain an understanding of the central concepts and techniques employed in computer programming, via the language Python.
- Students will learn about coding in Jupyter notebooks, and may be able to submit assignments in this form.
- Students will learn how to handle and manipulate data in computer code for the purposes of data analysis and graphing of results. They will be introduced to Python libraries, e.g., Numpy, Matplotlib, Pandas, which are widely used data analysis and data sciance.
- Students will learn how to visually present data and results programmatically.
- Students will learn how to visually present data using the Microsoft Power BI tool (incorporating Python code).
Assignment 1: Submit a working computer program along with a "User Manual" demonstrating basic data handling and analysis in Python, based on work done in class.
Assignment 2: Students will submit a working computer program (along with a written User Manual) manipulating and and analysing data employing tools from Python libraries such as Numpy, Matplotlib, Pandas, Statsmodels.
Assignment 3: Students will produce a data analysis report using the visualisation tool Power BI.