Lab 1: Thonny

In this course, we'll edit and run our Python code using Thonny.

Tip: To download Thonny on your personal computer at home, see the Software section of this website (Reference > Software).

Screenshot of the Thonny interface. Unfortunatley, Thonny has proved very impenetrable to screen readers after multiple attempts; we recommend you contact an instructor about alternatives.

Step 0) On your computer, using Spotlight, find and open Thonny.

Screenshot showing the use of Spotlight (on a Mac) to open Thonny, with the text 'thonny' typed in the Spotlight search window and the icon for Thonny being displayed as the top result.

Once Thonny is open, we want to create a Python file for today's lab and save it in the lab01 folder on your desktop. Here are the steps to do that...

Step 1) In the Untitled window, start out with this Python code, replacing the first line with your name and your partner's name.

Authors: Toni Morrison
Date: Sept 6, 2022
Purpose: CS111 Lab 1

print('hello world!')

The first six lines are a "docstring" (short for documentation string, where 'string' is just a fancy word for 'text') identifying the file and you should follow this pattern for all files you create in this course.

The final line is a simple print statement we'll use in a moment to confirm our program is running.

Your Thonny editor window should look like this):

A screenshot showing the code provided above displayed within Thonny.

Step 2) Save the file as in your lab01 folder on your Desktop. Click on the save icon in the upper left corner of the Thonny window

A screenshot highlighting the location of Thonny's Save command (it's the third icon in the menu bar).

Clicking on "Save" opens this window where you can type the name of the file Make sure you are saving the file in your lab01 folder and not on the Desktop.

The save-as dialog in Thonny on a Mac, with the show-details arrow highlighted. The dialog has fields for 'Save As', 'Tags', 'Where', and 'Format'. Only the 'Save As' (to name the file) and 'Where' (to select a folder) fields need to be edited. The show-details button immediately after the Where field allows selecting a destinaiton in detail.

You may need to click on the little down arrow (circled in green above) in order to select the lab01 folder before saving your file.

The expanded save-as dialog allowing detailed selection of a destination folder. This is the standard save-as dialog for a Mac.

Quick check: open your lab01 folder on your Desktop and verify that your folder is in there.

Run your file

Screenshot highlighting the location of the run button in Thonny, which is the fourth icon in the menu bar and comes right after the save button.

You can run your file via one of the following methods:

  1. Click on the Run Button (green arrow)
  2. Goto Run :: Run Current Script
  3. Use the keyboard shortcut F5

In this case, you'll know your program succesfully ran because it should say hello world! in the Python Shell, as shown below:

Screenshot showing that the text 'hello world!' appears in Thonny's 'Shell' region after running the code that was supplied above.


Learn the terms editor, shell and assistant in Thonny; we'll use these throughout the semester.

Screenshot summarizing the three main panels in Thonny: the Editor (where you will write your code), the Shell (see the results of running code; can also type directly in Shell), and the Assistant (live python feedback).

Table of Contents