No history yet

Python Basics

What Is Python?

Think of a programming language as a set of instructions for a computer. Just like you use English or Spanish to communicate with people, you use a programming language to tell a computer what to do. Python is one of the most popular programming languages in the world.

Why is it so popular? Python's syntax, its rules for writing code, is clean and easy to read. This makes it a great choice for beginners. But it's also powerful enough for experts at companies like Google, Netflix, and NASA. Python is used for everything from building websites and analyzing data to creating artificial intelligence.

Lesson image

A Quick History

Python was created in the late 1980s by a Dutch programmer named Guido van Rossum. He wanted to make a language that was both powerful and easy to read. He named it after the British comedy group Monty Python, not the snake.

One of Python's core principles is that code should be readable. Simple is better than complex.

Over the years, Python has grown thanks to a huge community of developers who contribute to it. They create and share packages, which are bundles of code that extend Python's capabilities. This means you don't have to start from scratch for every task. Need to work with data? There's a package for that. Want to build a game? There's a package for that too.

Setting Up Your Environment

Before you can write Python code, you need to install it on your computer. While some operating systems like macOS and Linux come with a version of Python pre-installed, it's always best to install the latest official version.

You can download Python for free from the official website, python.org. The installer will guide you through the setup process. During installation on Windows, make sure to check the box that says "Add Python to PATH." This lets you run Python easily from your computer's command line.

Lesson image

Running Your First Script

It's a tradition for new programmers to start with a "Hello, World!" program. It's a simple program that just prints that phrase to the screen. It confirms that your setup is working correctly.

First, open a plain text editor (like Notepad on Windows or TextEdit on Mac) and type the following line of code. Don't use a word processor like Microsoft Word, as it adds extra formatting.

print("Hello, World!")

Save the file as hello.py. The .py extension is important; it tells the computer that this is a Python file.

Next, open your computer's terminal or command prompt. Navigate to the folder where you saved hello.py. Then, type the following command and press Enter:

python hello.py

If everything is set up correctly, you should see Hello, World! printed in the terminal. Congratulations, you've just run your first Python script!

Now that you've got the basics down, let's test your knowledge.

Quiz Questions 1/6

Who created the Python programming language?

Quiz Questions 2/6

What is the primary reason mentioned in the text for Python's popularity with beginners?