Getting Started – Python

Python in itself is a very friendly programming language, when we get to grips with writing code, once you grasp the logic, it will become very intuitive. Before we get hands-on with code, it’s useful to invest some time in learning more widely about Python. Let’s list off some key features of Python, to begin with.

Python is primarily an Object-Oriented Programming (OOP) language. OOP is a programming paradigm that organises itself around objects, rather than functions or logic. Don’t worry too much about what this means at this stage. Although if you start learning to program in other languages then it’s worth remembering.

Python is a “high-level” language, which means it’s more easily understood by humans. Since python is a high-level language, the computer has to interpret the code into a language the computer understands, which is machine code.

Coming from a psychology background, we reference research articles and use APA style formatting. Well, Python also has a style guide, called PEP 8 (https://peps.python.org/pep-0008/). It’s certainly good practice to get into the habit of having good style. Although, don’t stress too much about this as a beginner, what’s important to learn is the syntax.

Like natural languages, programming languages have syntax. The syntax is a set of rules that you must follow to ensure your code can be interpreted by the computer. If your syntax is not correct, when you try to run your code, you will receive an error. Don’t be scared of errors, when programming you’re going to come across a lot of them.

To write any python code, we’re going to need a code editor or Integrated Development Environment, IDE for short. My personal favourite IDE is one called Spyder. If you’re wanting to run code then this is the bare basics of what you need. However, as you get more advanced with your coding, you may wish to add libraries to your code, in which case I recommend using Anaconda. Anaconda is a distributor that you can install which installs your IDE for you and manages libraries. Don’t worry if you find this confusing to begin with, it’ll make more sense as you learn more. For now, all you need to know is that we’re going to be opening Anaconda and using Spyder through Anaconda.

Please see Anaconda’s website for installation information: https://docs.anaconda.com/anaconda/install/.

Note to create a new environment in Anaconda so we’re not using the base (root).

Talk through the editor, console & inspector…

A lot about programming is problem-solving and there is no way you’re going to remember every function. You’re going to have to get used to looking things up, my favourite resource for python knowledge is https://www.w3schools.com/python

Course Author


Paige Metcalfe
c.p.metcalfe@salford.ac.uk