DocsHub

Introduction

A complete guide to Python — from your first line of code to advanced topics like async, decorators, and metaclasses.

Python

Python is one of the most popular programming languages in the world — and for good reason. It is simple enough for beginners to learn quickly, yet powerful enough to build real-world software used by companies like Google, Netflix, Instagram, and NASA.

This section covers Python from the ground up. Whether you have never written a line of code before, or you already know another language and want to learn Python, this guide is built for you.


What you will learn


A quick taste of Python

Before diving in, here is what Python looks like. Do not worry about understanding everything yet — just notice how readable it is.

# A simple function that greets someone
def greet(name):
    return f"Hello, {name}!"

print(greet("world"))  # Hello, world!

# A list of numbers and a loop
numbers = [1, 2, 3, 4, 5]

for number in numbers:
    if number % 2 == 0:
        print(f"{number} is even")
    else:
        print(f"{number} is odd")

Python reads almost like plain English. That is intentional — it is one of the core design goals of the language.


How Python compares to JavaScript

If you have already gone through the JavaScript section, here are the biggest differences to keep in mind:

JavaScriptPython
let x = 5x = 5
console.log()print()
Curly braces {} for blocksIndentation (spaces) for blocks
Semicolons (optional)No semicolons
=== for equality== for equality
nullNone
true / falseTrue / False
// comment# comment

Python uses indentation (spaces or tabs) to define code blocks instead of curly braces. This is not just style — it is required syntax. Inconsistent indentation causes errors.


Python versions

This guide uses Python 3.10+. Some topics (like match/case pattern matching) require Python 3.10 or newer. Python 2 is no longer supported and should not be used for new projects.

To check your version:

python3 --version
# Python 3.12.0

Ready? Start with the Basics section.

On this page