No history yet

Introduction to Python

Meet Python

Python is a popular, high-level programming language known for its simplicity and readability. It was created in the late 1980s by Guido van Rossum, a Dutch programmer. Fun fact: he named it after the British comedy group Monty Python, not the snake.

Van Rossum's goal was to create a language that was easy to read and write. The core philosophy is often summarized in a document called "The Zen of Python," which includes principles like "Beautiful is better than ugly" and "Simple is better than complex." This focus on clarity means you'll spend less time figuring out what code does and more time making it work.

Why It's So Popular

Python's popularity isn't just about its clean look. It's a powerhouse used for everything from web development and data analysis to artificial intelligence and scientific computing. This versatility is one of its biggest strengths.

Lesson image

Here are a few key reasons developers choose Python:

FeatureDescription
Easy to LearnThe syntax is straightforward and reads almost like English.
VersatileIt's a general-purpose language used in countless industries.
Large CommunityA huge global community means plenty of support and free resources.
Extensive LibrariesIt has a massive collection of pre-written code (libraries) for almost any task.

The Rules of the Road

Every programming language has its own set of rules, called syntax. Python's syntax is famously clean, but it has one rule that's especially important: indentation.

Unlike many other languages that use brackets or keywords to group code, Python uses whitespace. How you indent your code determines how it's structured and executed. This isn't just for style; it's a rule the language enforces.

In Python, indentation matters. It's how the computer understands which lines of code belong together.

For example, this is how you'd group a print statement inside another block of code. Notice the space before print:

# Correct Indentation
if True:
    print("This is inside the 'if' block.")

If you forget to indent, Python won't know what to do and will give you an error.

# Incorrect Indentation (will cause an error)
if True:
print("This will break the program.")

Your First Program

Let's get Python running on your computer and write your first program. You can download the latest version from the official website, python.org. The installation is straightforward, and the site has guides for Windows, macOS, and Linux.

Lesson image

Once Python is installed, you can write code in a simple text editor. However, most developers use an Integrated Development Environment (IDE), which provides helpful tools like syntax highlighting and debugging. Python comes with a basic IDE called IDLE, which is great for beginners.

Lesson image

It's a tradition in programming to make your first program display the message "Hello, World!". In Python, this is incredibly simple. Open IDLE or your chosen editor, type the following line, and run it.

print("Hello, World!")

The print() function is a built-in Python command that tells the computer to display whatever you put inside the parentheses. When you run this code, you should see the text Hello, World! appear on your screen.

Quiz Questions 1/6

Who is credited with creating the Python programming language?

Quiz Questions 2/6

The Python language was named after the large, nonvenomous snake.

And that's it! You've just written and executed your first piece of Python code. You're now ready to explore what else this powerful language can do.