Python Introduction

Tutorial 1 of 65 · pythondeck.com Python course

Python is a high-level, interpreted, general-purpose programming language created by Guido van Rossum in 1991. It emphasises readability through significant indentation and a clean syntax. Python is dynamically typed and garbage-collected, supports multiple paradigms (procedural, object-oriented, functional) and ships with a large standard library. It is widely used for scripting, web back-ends, data science, machine learning, automation and GUI applications.

Python is a high-level, interpreted language designed for readability and rapid development. Its clear syntax lets you express algorithms in fewer lines than many languages, which makes it a strong first language and a practical choice for automation, data work, and web backends.

Unlike compiled languages that require a separate build step, you typically edit a .py file and run it immediately with the interpreter. That feedback loop encourages experimentation and helps beginners see cause and effect without fighting tooling first.

Python runs on an interpreter (CPython is the reference implementation) that executes bytecode.

The standard library ships batteries included: files, networking, dates, and more without extra installs.

Indentation defines code blocks instead of braces, so consistent spacing is part of the language rules.

Everything is an object: numbers, functions, and modules have types and can be passed around.

The REPL and scripts share the same syntax; use the REPL to probe APIs, scripts for repeatable work.

PEP 8 and community conventions guide naming and layout even though the interpreter does not enforce style.

Python targets multiple domains—scripting, data science, DevOps, education—because its ecosystem grew around extension modules and pip-installable packages. You learn core language features once, then specialize with libraries like NumPy, Flask, or asyncio rather than switching languages.

Version 3.x is the only supported line today; Python 2 is obsolete. New projects should pin a 3.10+ interpreter and use virtual environments so dependencies stay isolated per project.

Reading tracebacks is a core skill: the bottom line names the exception, and the stack shows which file and line triggered it. Treat errors as navigation, not failure.

Assuming Python 2 syntax or print statements on a modern 3.x install.

Mixing tabs and spaces in the same file, which causes IndentationError unpredictably.

Installing packages globally with pip instead of inside a virtual environment.

Naming a script random.py and shadowing the standard library module of the same name.

Create a dedicated project folder and a virtual environment before installing third-party packages.

Run python --version and document the version your team uses.

Use meaningful script names and the if __name__ == "__main__": guard for entry points.

Keep the official tutorial and library reference bookmarked for authoritative definitions.

Re-read the examples below with these ideas in mind; change variable names and inputs to match your own project.

The program below demonstrates hello world. Read the comments on each line, run the code, then change names or values to see how the output shifts.

# Example: Hello World
# Run in the REPL or save as a .py file and execute with python.
print("Hello, World!")

This sample walks through quick math in a small, runnable script. Paste it into the REPL or save it as a .py file before you continue to the next block.

# Example: Quick math
# Run in the REPL or save as a .py file and execute with python.
print(2 + 3 * 4)
print(10 / 3)     # true division -> 3.333...
print(10 // 3)    # floor division -> 3
print(2 ** 10)    # power -> 1024

Here is a hands-on illustration of variables and print. Follow the inline comments first; only then execute the snippet and compare the result with what you expected.

# Example: Variables and print
# Run in the REPL or save as a .py file and execute with python.
name = "Ada"
age = 36
print(f"{name} is {age} years old.")

The program below demonstrates repl version probe. Read the comments on each line, run the code, then change names or values to see how the output shifts.

# Launch interactive Python: type `python` in a terminal
import sys  # standard module for interpreter details
print(sys.version)  # full version string with build info
print(sys.executable)  # path to the binary actually running
print(sys.platform)  # win32, linux, darwin, etc.
names = ["Ada", "Grace", "Linus"]  # sample list of strings
for person in names:  # loop prints each name on its own line
    print(f"Hello, {person}!")  # f-string formats text inline
total = sum(range(1, 6))  # 1+2+3+4+5 without manual addition
print("sum 1..5 =", total)  # quick arithmetic sanity check
pi_approx = 22 / 7  # float division always returns float in 3.x
print(round(pi_approx, 4))  # round to four decimals for display

This sample walks through script entry guard in a small, runnable script. Paste it into the REPL or save it as a .py file before you continue to the next block.

# Save as hello_intro.py and run: python hello_intro.py
def greet(name: str) -> str:  # function encapsulates reusable logic
    return f"Welcome, {name}"  # return value goes back to caller

def main() -> None:  # main holds top-level program steps
    message = greet("PythonDeck")  # call with a literal argument
    print(message)  # stdout is the default teaching output
    print(__name__)  # shows __main__ when executed as script

if __name__ == "__main__":  # guard prevents run on import
    main()  # only the script entry point invokes main()
# Importing this file elsewhere skips main() automatically

All tutorials Install Python »