W3docs

Python Intro

A practical introduction to Python: what it is, why developers choose it, how to install it, and your first working programs with clear examples.

Python is a high-level, general-purpose programming language created by Guido van Rossum and first released in 1991. It emphasizes readable code and a clean syntax that lets you express ideas in fewer lines than languages like C++ or Java. Today Python powers web backends, data pipelines, machine-learning models, automation scripts, and more — making it one of the most in-demand languages in the world.

This chapter answers four questions every beginner has: what Python actually is, why you should learn it, how to install it, and how to run your first program.

What Makes Python Different

Python is interpreted: code runs line-by-line through an interpreter at runtime, with no separate compilation step. That makes feedback fast — write a line, run it, see the result.

Python is also dynamically typed: you never declare a variable's type. The interpreter infers it from the value you assign.

x = 10        # x is an integer
x = "hello"   # now x is a string — no error

Python enforces readability through indentation. Blocks of code (functions, loops, conditionals) are delimited by indentation rather than curly braces. This forces a consistent style across every Python codebase.

def greet(name):
    if name:
        print("Hello, " + name)
    else:
        print("Hello, stranger")

Why Learn Python

Beginner-friendly syntax

Python reads almost like English. Compare adding two numbers in Java versus Python:

// Java
public class Add {
    public static void main(String[] args) {
        int result = 3 + 4;
        System.out.println(result);
    }
}
# Python
result = 3 + 4
print(result)

Less boilerplate means you spend more time on the problem and less time on ceremony.

Huge ecosystem

The Python Package Index (PyPI) hosts over 500 000 packages. Key areas include:

DomainPopular libraries
Web developmentDjango, Flask, FastAPI
Data scienceNumPy, Pandas, Matplotlib
Machine learningscikit-learn, TensorFlow, PyTorch
AutomationRequests, BeautifulSoup, Selenium
Scripting / DevOpsFabric, Ansible, Click

Versatility

The same language used to write a 10-line automation script is used by data scientists at Netflix, backend engineers at Instagram, and researchers training large language models. You rarely need to switch languages as your projects grow.

Strong job market

Python consistently ranks in the top three most-used languages in developer surveys (Stack Overflow, TIOBE, RedMonk). Demand for Python skills appears in data engineering, backend development, ML engineering, and scientific computing roles.

How to Install Python

Download from python.org

  1. Go to python.org/downloads.
  2. Download the installer for your operating system (Windows, macOS, or Linux).
  3. Run the installer. On Windows, check "Add Python to PATH" before clicking Install Now.

Verify the installation in your terminal:

python --version
# Python 3.12.x

On some systems (macOS, Linux) the command is python3:

python3 --version
# Python 3.12.x

The Python interactive shell (REPL)

The fastest way to experiment is the REPL (Read-Eval-Print Loop). Start it by typing python (or python3) with no arguments:

$ python
Python 3.12.3 (main, ...)
>>> 2 + 2
4
>>> print("Hello, world!")
Hello, world!
>>> exit()

Every expression you type is evaluated immediately and the result is printed. Use the REPL to test small snippets before putting them in a file.

Your First Python Program

Create a file called hello.py with any text editor and add:

# My first Python program
print("Hello, world!")

Run it from your terminal:

python hello.py
# Hello, world!

Adding real logic

Once print works, add variables and a calculation:

name = "Alice"
year_of_birth = 1995
current_year = 2025

age = current_year - year_of_birth

print("Name:", name)
print("Age:", age)

Output:

Name: Alice
Age: 30

No type declarations, no main() function, no semicolons — the interpreter handles it all.

Key Characteristics at a Glance

FeatureDetail
ParadigmMulti-paradigm: procedural, object-oriented, functional
TypingDynamic, strong
ExecutionInterpreted (CPython is the reference implementation)
IndentationMandatory — defines code blocks
LicensePython Software Foundation License (open source)
Current stablePython 3.x (Python 2 reached end-of-life in 2020)

What Comes Next

Now that you know what Python is and have it running, the natural path forward is:

Practice

Practice
Which of the following statements about Python are correct?
Which of the following statements about Python are correct?
Was this page helpful?