No history yet

Introduction to Python

What is Python?

Python is a programming language, a set of instructions we can give to a computer. What makes it special is its simplicity and readability. Its syntax is clean and looks a lot like plain English, which makes it one of the most beginner-friendly languages to learn.

But don't let its simplicity fool you. Python is incredibly powerful and versatile. It's used by major companies for a huge range of tasks. You can find it powering the backend of websites like Instagram and Spotify, analyzing massive datasets in scientific research, and automating repetitive tasks in offices around the world.

Lesson image

Whether you want to build a website, create a game, analyze data, or even get into machine learning, Python is a fantastic starting point.

Getting Python on Your Computer

Before you can start writing Python code, you need to install it. Think of this as giving your computer the ability to understand the Python language. The process is straightforward.

First, head to the official Python website at python.org. You'll see a downloads section with the latest version available for your operating system, whether it's Windows, macOS, or Linux.

Lesson image

Once you download and run the installer, you'll see a few options. There's one very important checkbox to look for on Windows: "Add Python to PATH." Make sure you check this box. It allows you to run Python from your computer's command line, which is very useful.

Always check the "Add Python to PATH" option during installation on Windows. It makes life much easier later on.

Follow the on-screen instructions to complete the installation. Once it's done, your computer is ready to understand and run Python programs.

Your Coding Workspace

While you can write code in a simple text editor, most programmers use an Integrated Development Environment, or IDE. An IDE is a special application that bundles together a text editor, a debugger to find errors, and other helpful tools to make coding smoother.

For beginners, a great choice is Thonny. It's an IDE built specifically for learning Python. It has a clean, simple interface and comes with Python already built in, so you don't have to configure anything. It's the perfect place to start your journey.

Lesson image

You can download Thonny for free from its website, thonny.org. Install it just like any other application, and you'll be ready to write your first piece of code.

Hello, World!

It's a tradition in programming to make your first program display the text "Hello, World!" on the screen. It's a simple way to confirm that everything is set up correctly.

Open Thonny. You'll see a main window for writing code (the editor) and a panel at the bottom called the "Shell." The shell is where you'll see the output of your programs.

In the editor, type the following line of code:

print("Hello, World!")

Let's break that down.

  • print is a built-in Python function. A function is a named block of code that performs a specific task. The print function's job is to display things on the screen.
  • The parentheses () after print are where we provide arguments, which are the inputs for the function.
  • "Hello, World!" is the argument we're giving to the print function. It's a piece of text, known as a string, and we always wrap strings in quotation marks.

Now, to run your program, click the green "Run" button at the top of the Thonny window (it looks like a play symbol). Thonny will ask you to save the file first. Save it with a name like hello.py. The .py extension is important; it tells the computer that this is a Python file.

After you click run, you should see the text Hello, World! appear in the shell at the bottom of the window. Congratulations, you've just written and run your first Python program!

Quiz Questions 1/6

Which of the following best describes the Python programming language?

Quiz Questions 2/6

When installing Python on Windows, what is the most important checkbox to select in the installer to ensure you can run Python from the command line?

That's all it takes to get started. You've installed the language, set up your coding environment, and executed your first command. You're now ready to explore what else Python can do.