Getting Started with Programming (using Thonny)

I thought it could be worth while to go through a quick “first program” using Thonny. If you didn’t see my last blog post, Thonny is a python code editor designed for people brand new to programming. You can download it here: https://thonny.org/

It’s easier than it looks.

The first time you open up Thonny, you get a pretty simple window with two mostly empty panels. The upper panel is where you write your code, and the lower panel is where you see the results of your programs and interact with them while they are running. So, let’s write our first program.

In the upper panel, write the line below, exactly as it is written.

print("It works!")

That’s it! You’ve written your first program. To run it, click the green circle with a white triangle inside it (the fourth icon in the row of icons above the upper panel). In general, this will simply run your program, but the first time you click it on a new file, it will ask you to save the file first. I recommend creating a new folder either on your desktop or in your documents folder, where you can save all of your Thonny projects. For simplicities sake, let’s call this “project1” and then click the “Save” button in the lower right corner of the save window.

Thonny will then save the file and run the program. When that happens, the lower panel should look very similar to this:

If you don’t see the words “It works!” in the middle, but see something in red instead, there was probably a typo in your code. Go back and double check that it is exactly like I typed it above (you can even copy and paste if you need) and then click the green Run button again.

What’s going on here?

There are two important things to know about what we’ve just done.

Firstly, we used a function called print(), which prints onto our screen whatever we put in between the brackets. Functions are like micro-programs that only do one thing. Most programs have many functions in them. We will make our own functions at some point, but most programming languages come with many functions built-in (the print() function is built into Python, which is the name of the programming language we’re using in Thonny), and some functions are written 

Secondly, the programming term for what we wrote between the brackets is called a string. Strings are like normal text/words. To write a string, you just need to put everything you want to be part of that string between two quotation marks. You can use double quotes, “like this,” or single quotes ‘like this.’ But whichever you use at the start of the string has to be the same as what you use at the end.

So, in the end, all we did was tell our computer to print the string “It works!” onto our screen. Simple. No, it’s not very exciting, but we’re just taking this slow, to make sure we can get a clear understanding of each step of the process.

Tomorrow (or soon after), we will tackle something called variables.

Programming Tools for Beginners

The first time I tried explaining how to get started with programming, I found that I spent an awful lot of time explaining how to get the right tools installed and configured just to be able to get to the point where the first line of code could be written. Since then, I’ve figured out which tools are better (or, at least, simpler) than others for people who are just getting started. But, just the other day, I stumbled across something that seems like it could be a terrific starting point for someone who just wants to get their feet wet without having to deal with the hassle of getting their computer set up for programming.

The Simpler the Better

It’s a program called Thonny. It is free and comes with everything you need to get started with programming in a single tidy little package. All you have to do is download it from thonny.org, install it onto your computer, and start it up. Then, there within that little window is everything you need to actually write your own programs.

Keep in mind, this is designed for total beginners. If you are already familiar with programming and file structures and things like that, this might be a little too “basic” for you, but it is actually still kind of fun if you want to check it out.

I think tomorrow (or some time very soon) I’ll do a quick-and-dirty “how to” with Thonny. Let’s have some fun!