No history yet

Python Basics

What Is Python?

Python is a programming language known for its clear, readable syntax. It was created in the late 1980s by Guido van Rossum, who wanted a language that was easy to learn and powerful enough for complex tasks. Think of it as a versatile tool, like a Swiss Army knife for coders. You can use it to build websites, analyze data, create games, or automate repetitive jobs.

One of its biggest strengths is its simplicity. Python reads a bit like plain English, which makes it a popular first choice for people new to programming. It also has a huge community of developers who have created thousands of free libraries—bundles of pre-written code you can use to get your projects up and running faster.

Lesson image

Getting Python Running

Before you can write Python code, you need to install it on your computer. Some operating systems, like macOS and Linux, come with an older version of Python already installed. However, it's always best to install the latest version to get all the new features and security updates.

You can download the official Python installer from python.org. The website automatically detects your operating system and suggests the correct version.

The installation process is straightforward. Just run the installer and follow the on-screen instructions. During setup on Windows, make sure to check the box that says "Add Python to PATH." This small step makes it much easier to run your code from the command line later on.

Lesson image

Your Coding Workspace

While you can write code in any basic text editor, most developers use an Integrated Development Environment, or IDE. An IDE is a special application that combines a text editor with other helpful tools, like a debugger for finding errors and a terminal for running your code.

Think of an IDE as a fully equipped workshop. It has everything you need in one place, which helps you work more efficiently. Popular IDEs for Python include Visual Studio Code (VS Code), PyCharm, and Thonny. They offer features like syntax highlighting, which colors your code to make it easier to read, and code completion, which suggests code as you type.

Lesson image

For beginners, an IDE like Thonny is a great starting point because it's designed specifically for learning Python and has a very simple interface. As you get more experienced, you might prefer the more powerful features of VS Code or PyCharm.

Your First Program

It's a tradition in programming to start by writing a program that simply displays "Hello, World!" on the screen. This confirms that your setup is working correctly. Let's do that now.

First, open your IDE or a plain text editor. Create a new file and type the following line of code:

print("Hello, World!")

Now, save the file with a .py extension, which tells your computer that it's a Python script. A good name would be hello.py.

To run your script, you'll use your computer's command line or terminal. If you're using an IDE, it probably has a built-in terminal or a "Run" button. In the terminal, navigate to the directory where you saved your file and type the following command:

python hello.py

If everything is set up correctly, you should see Hello, World! printed in the terminal. You've just written and executed your first Python program!

The print() function is one of Python's built-in tools. Its job is to display whatever you put inside the parentheses on the screen.

That's it. You've taken the first step into the world of programming with Python.

Quiz Questions 1/6

Who was the creator of the Python programming language?

Quiz Questions 2/6

According to the text, which of the following is a primary strength of Python, especially for beginners?