No history yet

Introduction to Python

What Is Python?

Python is a high-level, versatile programming language known for its simple and readable syntax. It's often said that Python code looks a lot like plain English, which makes it one of the easiest languages for beginners to pick up. But don't let its simplicity fool you; it's also powerful enough for major companies like Google, Netflix, and NASA to use for critical applications.

One of Python's greatest strengths is its versatility. You can find it powering a wide range of applications, from web development and data science to machine learning and system automation. This flexibility comes from a massive collection of libraries and frameworks built by its active community, allowing developers to accomplish complex tasks with relatively little code.

Lesson image

A Brief History

Python was created in the late 1980s by Guido van Rossum. He wanted to design a language that emphasized code readability and a simple, clean syntax. The first version was released in 1991. The name doesn't come from the snake, but from Guido's favorite comedy troupe, "Monty Python's Flying Circus."

The language's core philosophy is summarized in a document called the "Zen of Python," which includes principles like "Beautiful is better than ugly" and "Simple is better than complex."

Getting Started with Python

First, you'll need to install Python on your computer. The official place to get it is from the Python Software Foundation's website at python.org. You can download the latest version for your operating system (Windows, macOS, or Linux) and follow the installation instructions.

Lesson image

When you install Python, it also comes with a simple Integrated Development and Learning Environment called IDLE. IDLE includes a text editor for writing scripts and an interactive shell where you can experiment with code.

Lesson image

The interactive shell is also known as a REPL, which stands for Read-Eval-Print Loop. It's a great place to test small snippets of code without having to save them in a file. The shell reads the code you type, evaluates it, prints the result, and loops back to wait for your next command. You can start the REPL by opening your computer's terminal or command prompt and typing python (or python3 on some systems).

Let's try a simple calculation in the REPL. The >>> is the prompt, waiting for your input.

>>> 5 + 3
8
>>> 10 * 4
40

Your First Python Script

While the interactive shell is useful, you'll write most of your code in script files. A Python script is just a plain text file containing Python code. By convention, these files have a .py extension.

Let's write the classic "Hello, World!" program. Open any text editor (like IDLE, Notepad, or VS Code) and type the following line:

print("Hello, World!")

Here, print() is a built-in Python function that outputs text to the screen. The text you want to print goes inside the parentheses, enclosed in quotes.

Save this file as hello.py. To run it, open your terminal, navigate to the directory where you saved the file, and type:

python hello.py

You should see the text Hello, World! printed in your terminal. Congratulations, you've just written and executed your first Python script!

Now that you've got the basics down, let's check your understanding.

Quiz Questions 1/6

Who is the creator of the Python programming language?

Quiz Questions 2/6

Python's name was inspired by a species of snake.

Great work. You now have a solid foundation for your journey into the world of Python programming.