Skip to content

Python Basics

This page is a compact orientation to the language. It does not replace the chapter-style pages, but it gives you the right mental model before you go deeper.

Compared with many other mainstream languages, Python emphasizes:

  • readability over punctuation-heavy syntax
  • indentation as part of block structure
  • quick iteration in scripts, shells, and notebooks
  • a standard library that covers common tasks out of the box
name = "Ava"
count = 3
price = 19.99
active = True

Python variables are names bound to objects. You do not declare the type ahead of time.

numbers = [1, 2, 3]
point = (10, 20)
user = {"name": "Ava", "role": "admin"}
tags = {"python", "api", "automation"}
if count > 0:
print("positive")
else:
print("zero or negative")
for number in numbers:
print(number)
def greet(name: str) -> str:
return f"Hello, {name}"
  • use virtual environments per project
  • prefer python -m pip when you want the interpreter and package manager to match
  • keep scripts small and focused
  • name things clearly instead of over-compressing the code
  • add type hints when they improve clarity

Once you understand the basics, the next useful layers are:

  1. data structures
  2. functions and modules
  3. exceptions and file handling
  4. classes and object design
  5. packaging, environments, and tooling