No history yet

Python Setup

Getting Python on Your Machine

Before you can write any Python code, you need to install the Python interpreter. Think of the interpreter as a translator. It takes the code you write in Python and translates it into instructions your computer can understand and execute. The process is slightly different depending on your operating system.

Installation Steps

For Windows Users

Start by visiting the official Python website at python.org. You’ll see a prominent download button for the latest version of Python. Download the installer file.

When you run the installer, you'll be presented with a setup window. There's one very important checkbox you need to select on the first screen.

Lesson image

Make sure to check the box that says "Add python.exe to PATH." This allows you to run Python from your computer's command line, which is a useful tool for any programmer.

After checking that box, click "Install Now" and follow the on-screen prompts to complete the installation.

For macOS Users

Just like with Windows, you'll go to python.org to download the macOS installer package. Once downloaded, open the .pkg file to begin the installation. The process is straightforward; just follow the steps in the installation wizard, agreeing to the license and confirming the installation location.

Lesson image

For Linux Users

Most Linux distributions, like Ubuntu, come with Python pre-installed. You can check if you have it by opening your terminal and typing the following command:

python3 --version

If Python is installed, this will display the version number. If not, or if you need to install it, you can use your distribution's package manager. For Debian-based systems like Ubuntu, the command is:

sudo apt update && sudo apt install python3

Your Coding Environment

Now that Python is installed, you need a place to write your code. While you could use a simple text editor, most programmers use an Integrated Development Environment, or IDE. An IDE is a software application that provides comprehensive facilities for software development, typically including a source code editor, build automation tools, and a debugger.

For beginners, a simple and clean IDE is best. We recommend Thonny, which is designed for learning and teaching programming. It comes with Python built-in, so it's ready to go right after installation. You can download it from thonny.org.

Lesson image

Once you have Thonny installed and open, you'll see a main panel for writing code and a bottom panel called the "Shell," which is where you'll see the output of your programs.

Your First Script

Let's make sure everything is working correctly by writing a classic first program: "Hello, World!". This simple program just prints a message to the screen.

In the main editor panel in Thonny, type the following line of code:

print("Hello, World!")

This code uses the built-in print() function to display the text inside the parentheses and quotation marks. Now, you need to run it. You can either click the green "Run" button in the toolbar or press the F5 key on your keyboard.

Thonny will prompt you to save the file first. Save it with a name like hello.py. The .py extension is important as it tells the computer that this is a Python file.

After saving, the script will run. You should see the text Hello, World! appear in the Shell panel at the bottom of the Thonny window. If you see that message, congratulations! Your Python environment is set up and you've successfully run your first program.

Quiz Questions 1/5

What is the primary role of the Python interpreter?

Quiz Questions 2/5

When installing Python on Windows from python.org, what is the most critical checkbox to select on the initial setup screen to ensure Python is easily accessible from the command line?

With your environment set up, you're ready to start exploring the fundamentals of Python.