Getting Started in Python
What is a Program?
A computer program is a set of instructions that causes a computer to perform some kind of action. Like humans, computer use multiple languages to communicate – in this case programming languages. A programming language is a particular way to talk to a computer – a way to use instructions that both humans and the computer can understand.
Why Learn Programming?
- Helps improve your creativity, reasoning and problem solving
- Create something from nothing – give instructions to the computer to run that can perform a task or solve a problem
- Fun and challenging!
What is Python?
Python is a general purpose programming language created in the late 1980s, and named after Monty Python (a British TV comedy show), that’s used by thousands of people to do things like web development, testing microchips at Intel, to powering Instagram, to building video games with the PyGame library.
Why Python?
- Easy to learn and read
- Great for beginning programmers
- Interactive – can see results immediately
- Libraries and modules – reduces the amount of coding you have to do
- Great for graphics and animation, for example, creating games
- It’s free!
In Chromebooks, the Python programming language runs on the Linux operating system.
The Thonny Editor
Thonny is a free beginner-friendly Python Integrated Development Environment (IDE) editor. Think of Thonny as the workroom in which you will create amazing Python programs. Your workroom contains a toolbox containing many tools that will enable to you create and run Python programs.
To open the Thonny editor, go to applications and click on the “Th” (Thonny) icon.
When you open the Thonny application opens you should see a window with several icons across the top, and two white areas.
Across the top you’ll see several icons. Let’s explore what each of them does. You’ll see an image of the icons below, with a letter above each one. We will use these letters to talk about each of the icons:
- The paper icon allows you to create a new file. Typically in Python you want to separate your programs into separate files. You’ll use this button later in the tutorial to create your first program in Thonny!
- The open folder icon allows you to open a file that already exists on your computer. This might be useful if you come back to a program that you worked on previously.
- The floppy disk icon allows you to save your code. Press this early and often. You’ll use this later to save your first Thonny Python program.
- The play icon allows you to run your code. Remember that the code you write is meant to be executed. Running your code means you’re telling Python, “Do what I told you to do!” (In other words, read through my code and execute what I wrote.)
You are now ready to write and run your first Python program!
Your First Python Program
Select the “File” option on the top menu and choose “New.”
Type the following code:
print (3 * 5)
Now click on the green “Run” button on the toolbar.
The Thonny editor will then prompt you to save your file. Give your file a name and click “Save.”
Your program will now execute and display the output in the shell (bottom window pane).