A Python Course

2020-11-05

Recenty I've been asked whether I could teach Python to a fellow PhD student and said yes. My plan was not to invest too much time into this, and just assemble a list of resources to read, and a few practice tasks. However, by now two more people have asked whether they could join, so I decided to gather everything in one place and this place is here.

I will update this post when I add new posts that belong to this course, and it will be notoriously incomplete for quite some time. This course is not a "self study" course. So if you are some innocent reader, that was not directed here by me, I'd actually not recommend trying to learn python using this class (unless you have someone else who can hold your hand).

The people I teach all have some programming exerience with Matlab or R, i.e. they know what functions, variables or a loops are, but they have no CS background what so ever. They need Python to write psychological paradigms and do data analysis, and this course is geared towards them.

The "Curriculum"

  1. The first thing I hand out to them is this pdf. It was originally part of my PyParadigm paper, when I tried to publish it in response to a "Call for tutorial Papers" in some psychology journal, but it was rejected. It was co-authored by Johannes Petzold and Michael Marxen.

  2. Write the "Number guessing game".

    Description: The program chooses a random number between 1 and 100 and then gets a number from the player (and it shouldn't crash if s/he enters something that is not a number). If the number is correct, the player wins, otherwise s/he's given a hint whether the guessed number was too low or too high and can go again. After 10 missed trials the player lost.

    The important thing here mainly is to get them to use functions and not write everything as one big block of code. Later, I might add a solution as well as the most common problems.

  3. Write a Black Jack game.

    It gets a little more complex now. Additionally to the actual Black Jack game, they should also record subject reaction times and decisions. I'll have them read up on pathlib, and json, as well as NamedTuple, and Enums and instruct them to use a NamedTuple of two enums to represet a Card, and that they should use json.dumps in combination with Path.write_text to store the recorded data.

    Once this is working I'll have them read PyParadigm's tutorial and then port the Black Jack from console to GUI using PyParadigm. This set of card images can be used.

  4. The next thing would then be to do some analysis with the data that is generated by the paradigm, but that hasn't happened so far, and Ill update this later. However, there is quite some things left they need to know about Python at this point, and I'll sprinkle them in between practical exercises. So the next thing to read is:

To do some analysis, they should also read introductory tutorials for numpy (alternative, if no matlab experience) and pandas. Last but not least, an environment is needed to do the analysis in. Most people would probably recomend jupyter. I wrote a post about this topic for this course: An Introduction to Jupyter - and why I don't like it