Chunyun Ma, PhD Candidate in Psychology, Carleton University
Why do I want to learn python?
There is the thrill of learning something new. There is also the practical part. I will focus on the latter today.
I study math cognition. What is that? You may ask. Simply put, I spend most of time studying how people process numbers and quantities. Several months ago, I become interested at how people do arithmetic. Not to bore you with the details, I needed to design an experiment in which participants would be doing mental addition and multiplication—all one-digit problems such as “2+3” or “3*5”. These problems would show up on a computer screen at a pre-determined interval for participants to solve. Everything seemed straightforward and easy except for one: I had more than 300 arithmetic problems to be included in the experiment. With the software I had at that time, each problem needs to be set up manually by point-and-click for it to show up properly on the screen.
Hours of point-and-click eventually led me to think: “there must be a smarter way of doing this”. Sure enough, Python entered my horizon at that time and proved to be much more efficient. With python, like with many other programming languages, I can write the code for presenting one arithmetic problem and recycle it for the rest of the problems. What’s better, I can stipulate in the code what output should be generated and in what format.
The advantage of Python over other programming languages is that it is relatively easy to learn. For psychology folks, knowing python also has an added bonus—being part of a vibrant community consisting of python users from all over the world who are knowledgeable of both python and experimental design. For example, Pygame and PsychoPy are two excellent tools for designing experiments, both of which are products through collective effort from the community.