No history yet

Python Installation

Getting Python on Your Machine

Before you can start writing Python code, you need to install the Python interpreter. This is the core program that understands your code and executes your commands. The best place to get it is from the official source, python.org.

Head to the downloads page and grab the latest version for your operating system (Windows, macOS, or Linux). Running the installer is straightforward, but there's one crucial step for Windows users: make sure to check the box that says "Add Python to PATH." This allows you to run Python from your computer's command line, which is a handy tool we'll use shortly.

Lesson image

Your First Conversation with Python

Once installed, you can talk directly to Python using its interactive shell. This is a command-line tool that reads a single line of code, runs it, and prints the result. It's perfect for quick tests and experiments. To start it, open your computer's command prompt (or Terminal on a Mac) and type python or python3, then press Enter.

You'll know it worked if you see a prompt that looks like >>>. Now you can give it commands.

>>> 2 + 2
4
>>> print("Hello, interactive world!")
Hello, interactive world!

This immediate feedback is great for learning. You can test a small piece of logic without needing to create a file first. To exit the shell, type exit() and press Enter.

Setting Up Your Workspace

While the interactive shell is useful, you'll write most of your code in files. To manage these files and make coding easier, programmers use an Integrated Development Environment, or IDE. An IDE is like a specialized workshop for writing code. It bundles a text editor, a way to run your code, and other helpful tools into one application.

There are many IDEs, but a fantastic one for beginners is Thonny. It's designed specifically for learning, with a simple interface that won't overwhelm you. The best part? Thonny comes with its own version of Python, so installing Thonny is all you need to do to get started.

Lesson image

When you open Thonny, you'll see two main parts. The top area is the script editor, where you'll write and save your code files (which end in .py). The bottom area is the shell, just like the interactive one we used earlier. You can write code in the editor, save it, and then click the green "Run" button to execute the entire file. The output will appear in the shell below.

Try it out! Type print("Hello from my first script!") into the editor, save the file as hello.py, and press the run button.

With Python installed and Thonny set up, you now have a complete environment for writing and running your own programs.