Introduction to Python — a beautifully formatted beginner's guide with live syntax-highlighted code blocks.

Programming language guide

Introduction to Python

Simple syntax. Massive power. Whether you're building websites, training AI models, or automating everyday tasks — Python does it all.

Created 1991 Free & open source Cross-platform Beginner friendly 500k+ packages
What is Python

Python is a high-level programming language created by Guido van Rossum in 1991. It uses English-like syntax so you can focus on solving problems, not fighting the language.

Readable syntax
Reads like plain English — minimal boilerplate, maximum clarity.
Cross-platform
Runs on Windows, macOS and Linux with zero code changes.
Huge ecosystem
Over 500,000 packages on PyPI for almost any use case.
Interpreted
Runs line-by-line — no compilation step needed, easy to debug.

Real-world uses
Web dev
Web Development
Django · Flask · FastAPI
Data science
Data & Analytics
Pandas · NumPy · Matplotlib
AI / ML
Artificial Intelligence
TensorFlow · PyTorch · Scikit-learn
Automation
Task Automation
Emails · Scraping · File tasks

Installing Python
1
Go to python.org and download the latest version for your OS.
2
Run the installer — check "Add Python to PATH" before clicking Install Now.
3
Open Terminal or Command Prompt and verify your installation.
terminal
# Verify installation in terminal
python --version

# Expected output:
Python 3.x.x

Your first Python program

Save the file as hello.py, then run it from your terminal with python hello.py.

hello.py
# hello.py — your very first Python program
print("Hello, World!")

# Run it from your terminal:
#   python hello.py

# Output:
Hello, World!

Python syntax basics
Variables
No type declaration needed — Python infers the type automatically.
Indentation
Python uses spaces/tabs instead of curly braces to define blocks.
Comments
Use # for single-line comments to explain your code.
Functions
Defined with def keyword — reusable blocks that take inputs and return outputs.
syntax_basics.py
# Variables — no type declaration needed
name = "Vivaan"
age  = 25
pi   = 3.14

# Indentation replaces curly braces
if age > 18:
    print("Adult")
else:
    print("Minor")

# Functions
def greet(name):
    return f"Hello, {name}!"

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

# Lists
languages = ["Python", "JavaScript", "Rust"]
for lang in languages:
    print(lang)

Frequently asked questions
What is Python used for?
Web development, data science, artificial intelligence, automation, scripting, game development, and much more.
Is Python easy for beginners?
Yes — it's consistently ranked the most beginner-friendly language. Most people grasp the basics within 4–6 weeks of daily practice.
Do I need a powerful computer?
No. Python runs comfortably on basic and older machines — even a modest laptop is more than enough to start.
Is Python free?
Completely free and open-source, licensed under the Python Software Foundation licence.
Can I get a job after learning Python?
Yes — Python developers are in high demand across data science, backend development, ML engineering, and DevOps roles.
How long does it take to learn Python?
Basics in a few weeks with daily practice. Proficiency for real-world projects typically takes a few months.

Career Changer

Become a Developer in 6 Months

No degree? No problem. Treehouse Techdegrees give you the skills, the portfolio, and the certificate to land your first tech job.

6 mo
To job-ready
50%
Discount
Cert.
Included
Claim Your 50% Discount Now →