Course Setup

Getting Started

We will be using the Python progamming language to write all of the code for this course but, we need tools that can:

  1. allow us to edit plain text files for writing code
  2. take our code and help the computer to understand what instructions to perform

Lucky for us, we have one program that can do both things!

It is recommended to install and use Thonny to develop your programs. Thonny is a type of program called an Integrated Development Environment (IDE). An IDE usually combines that ability to write, run, and debug your code into one application. Thonny does all this, and provides a convenient means to install and manage additional packages to provide extra features that are not a part of the standard Python programming language. If you have issues with Thonny, you can try the Mu Editor instead. Both editors are very similar and focus on ease of use rather than an abundance of extra features. To stay consistent, I also will use Thonny in class.

Both editors can be installed by running (double clicking) the installers for your operating system of choice (Mac or Windows) and following the installation prompts (the defaults should be sufficient).

With Thonny or Mu installed, you are offically ready to write programs!

A Little Background

What is Python exactly?

Python actually has two different meanings in the context of witing our programs.

  1. Python the Programming Language
  2. Python the Interpreter

Python the Language

When we write code, we do so using the Python programming language. This is language is like any other you might speak or read and has a grammar which defines all the rules of the languages. As you write code, you will need to make sure that each line of code is syntactically correct so the statements you write are coherent to the computer.

Let’s say we want to add two numbers together and store them. In Python, we can say:

x = 1 + 2

This would store the value 3 in x. Notice how the equals is on the left hand side of the expression. This is a grammar rule of Python, but not all programming languages, so if we were to accidentally switch the order:

1 + 2 = x

We would create a Syntax Error and make the statement invalid in the Python language. This is like saying “Dogs the in walk the Tuesday on park”, the words are there, but they do not make sense as written if we read them left to right. Worse yet, trying to interpret them could lead to ambiguous meanings. For example, that sentence could be:

While people can use logic and previous experience to try and bridge gaps in understanding when things are imprecise, computers are not like people and struggle with ambiguity. Computers require a high degree of specificity to accomplish their tasks correctly.

Python the Interpreter

After talking about the Python the language, the question might arise as to what actually makes sure the code we write is syntactically correct? For the Python programming language, this is done with a program called an interpreter which is also named Python. This program reads your code line-by-line and acts as an intermediatary to perform the operations you have described in your code. This is similar to how an linguistic interpreter might allow two people who understand different languages to communicate together.