No history yet

Setup and Basics

Setting Up Your Workspace

Before you can write any Python code, you need two things: the Python language itself and a place to write it. First, you'll need to install Python on your computer. It's a free programming language that you can download from the official Python website. The installation process is straightforward, much like installing any other application.

Lesson image

Next, you need a code editor. Think of it as a word processor specifically for writing code. It helps you by color-coding your text to make it more readable and can catch simple mistakes. For beginners, editors like Thonny are great because they are simple and designed for learning. Another very popular choice is Visual Studio Code, which is a more powerful IDE you can grow into.

Writing Your First Program

It's a tradition in programming to make your first program display the message "Hello, World!". This simple task confirms that your setup is working correctly. In Python, we use a built-in command called the print() function to display text on the screen.

A function is a reusable block of code that performs a specific action. You "call" a function by writing its name followed by parentheses.

To tell Python that you want to print text, you must put the text inside the parentheses and enclose it in either single (') or double (") quotation marks. This tells Python that it's looking at a piece of text, which programmers call a "string".

print("Hello, World!")

Running Your Code

Once you've written your code, save the file. It's a standard practice to give Python files a name that ends with the .py extension, like hello.py. This extension tells your computer that it's a Python file.

The rules for how you must structure your code, like using parentheses for print() and quotes for text, are called the language's . If you get the syntax wrong, the computer won't understand your instructions.

Python is an . This means that a program called the interpreter reads your code line by line and executes the instructions immediately. To run your file, you'll open a terminal (or console) on your computer, navigate to the directory where you saved your file, and type python hello.py. When you press Enter, you should see Hello, World! printed on the screen.

Lesson image

Now that you've run your first program, let's test your understanding of these basic concepts.

Quiz Questions 1/6

What are the two essential things you need to get started with writing Python code?

Quiz Questions 2/6

In Python, a piece of text like "Hello, World!" that is enclosed in quotation marks is called a what?

Congratulations! You've successfully installed Python, written your first lines of code, and seen it run. You are now officially a Python programmer.