We've been working through a PHP series for the beginners among us, and a few of you asked for the same treatment for Python. So let's start one. Same approach: short, hands-on lessons that take you from absolute beginner to comfortably intermediate, one step at a time.
This first part covers the basics — what Python is, how to run it, and the syntax rules you'll lean on in every program after this.
What is Python?
Python is a free, open-source, general-purpose programming language. It was created by Guido van Rossum and first released in 1991, and it's designed around one big idea: code should be easy to read. That focus on readability is a large part of why it's one of the most popular languages for beginners and professionals alike.
Unlike PHP — which was built for the web — Python is a true all-rounder. People use it for:
- Automation and scripting — gluing tasks together, renaming files, scraping data.
- Web development — with frameworks like Django and Flask.
- Data science, machine learning, and AI — the dominant language in this space.
- Tooling and back-end services of all kinds.
Why Python?
- It's free and open source.
- It runs on Windows, macOS, and Linux.
- The syntax is clean and close to plain English, so there's less to memorize up front.
- It comes with a huge standard library, plus tens of thousands of third-party packages.
Note: there are two big versions in the wild — Python 2 and Python 3. Python 2 is end-of-life and you should not use it. Everything in this series uses Python 3, which is what you get from a modern install.
Running Python
PHP needed <?php ?> tags because it's embedded inside HTML. Python has no tags at all — a Python program is just a plain text file, saved with a .py extension, that you run from your terminal.
Let's make the classic first program. Create a file called hello.py with one line in it:
print("Hello, Coders Republic!")
Then run it from your terminal:
python3 hello.py
You'll see:
Hello, Coders Republic!
There's also an interactive mode (the REPL). Just type python3 with no filename and you get a prompt where each line runs immediately — great for trying things out:
>>> 2 + 2
4
>>> print("hi")
hi
The print() Function
In PHP we used echo to output text. In Python, the equivalent is the built-in print() function. Unlike echo, it does use parentheses, and the text goes inside quotes:
print("Python is fun!")
You can use single or double quotes — both work, as long as you're consistent on each end:
print('Single quotes work too.')
And notice something important: there's no semicolon at the end. In Python, a line ending is enough to finish a statement. You can add a ;, but it's considered un-Pythonic — leave it off.
Indentation Matters (the big one)
Here's the rule that surprises everyone coming from PHP, JavaScript, or C: Python uses indentation — the spaces at the start of a line — to define which code belongs together. Other languages use curly braces { }; Python uses whitespace.
We'll cover conditions properly later, but here's a preview so you can see it:
age = 20
if age >= 18:
print("You are an adult.")
print("Welcome in.")
The two indented lines belong to the if. The colon (:) opens the block, and the indentation says "these lines run together." Get the indentation wrong and Python will stop with an IndentationError — it's strict on purpose, because it forces clean, readable layout.
Note: the standard is 4 spaces per level. Pick spaces or tabs and never mix them in one file — mixing them is a classic beginner bug.
Comments
Just like any language, you can leave notes in your code that Python ignores when it runs. A single-line comment starts with a hash #:
# This is a comment — Python skips it
print("This line runs.") # comments can also sit at the end of a line
Python has no dedicated multi-line comment syntax. For a few lines, just start each with #. You'll also see people use a triple-quoted string for longer notes:
"""
This is technically a string, not a comment,
but it's commonly used to document code across
several lines (especially at the top of functions).
"""
Strictly speaking that's a string literal that Python evaluates and discards, not a true comment — but when it's used to describe a function (a docstring), it's the standard Python way to document code.
To Be Continued…
That's the foundation: you can run a script, print output, and you understand Python's two signatures — no semicolons, and indentation that actually means something. In Part 2 we'll cover Variables and Data Types — how Python stores text, numbers, and more. Stay tuned!