Python Tutorial #2: Installing Python and Your First Program

In the previous tutorial, we learned what Python is and why it is worth learning. Now it is time to install it and write your first program. By the end of this tutorial, you will have Python running on your computer. You will know how to use the Python REPL, write a script, and run it from the terminal. Installing Python Python works on macOS, Linux, and Windows. Let me show you how to install it on each system. ...

April 24, 2026 · 9 min

Python Tutorial #1: Why Python? A Simple Guide for Developers

Python is the most popular programming language in the world right now. It has been the number one language on the TIOBE Index since 2021 and holds a record-breaking 26% rating in 2025-2026. But why? What makes Python so popular? And should you learn it? In this tutorial, we will answer these questions. By the end, you will understand what Python is, where it is used, and why it is worth learning in 2026. ...

April 24, 2026 · 9 min

10 Python Concepts Every Developer Must Know

These ten concepts appear in almost every Python project. If you know all of them, you can read and write real Python code. If you are missing one, that is the one that trips you up on every project. 1. Variables and Data Types Python infers types automatically. No declaration needed. name: str = "Alex" age: int = 25 score: float = 9.5 active: bool = True nothing = None print(type(name)) # <class 'str'> The four built-in collection types: numbers = [1, 2, 3] # list — ordered, mutable point = (10, 20) # tuple — ordered, immutable tags = {"python", "dev"} # set — unique items user = {"name": "Alex", "age": 25} # dict — key/value pairs Use type() to check the type of any variable at runtime. Use type hints for documentation and IDE support. ...

April 14, 2026 · 5 min

Getting Started with PyTorch: Tensors, Autograd, and Your First Neural Net

PyTorch is the standard framework for deep learning research and production. Most AI papers, Hugging Face models, and state-of-the-art systems use PyTorch. This article gets you from zero to a working neural network. Setup pip install torch torchvision import torch print(torch.__version__) # 2.x print(torch.cuda.is_available()) # True if you have a GPU Tensors A tensor is the fundamental data structure in PyTorch. It is like a NumPy array, but it can run on GPU and supports automatic differentiation. ...

March 29, 2026 · 5 min

How Neural Networks Work: A Developer's Guide

Neural networks power most AI you use today. ChatGPT, image recognition, voice assistants — all neural networks. You do not need a math degree to understand them. This article explains the concepts clearly, with code examples in plain Python and PyTorch. What Is a Neural Network? A neural network is a function. It takes numbers in, does math, and produces numbers out. That’s it. The magic is in how it learns which math to do. ...

March 28, 2026 · 5 min

Your First Machine Learning Model with scikit-learn

You know NumPy and Pandas. Now it is time to train a model. scikit-learn is the standard library for machine learning in Python. It is simple, well-documented, and works for most real-world tasks without a GPU. Setup pip install scikit-learn pandas numpy import sklearn print(sklearn.__version__) # 1.5+ The ML Workflow Every supervised ML task follows these steps: 1. Load data 2. Prepare features (X) and target (y) 3. Split into train and test sets 4. Train a model 5. Evaluate on test set 6. Make predictions on new data Let’s go through each one. ...

March 28, 2026 · 4 min

NumPy and Pandas for Machine Learning: A Practical Crash Course

Before you train any machine learning model, you need to handle data. NumPy and Pandas are the two libraries you will use every day. This is a practical crash course. No theory — just the operations you actually need. Setup pip install numpy pandas Check versions: import numpy as np import pandas as pd print(np.__version__) # 2.x print(pd.__version__) # 2.x NumPy: Arrays NumPy gives you fast multi-dimensional arrays. They are faster than Python lists for math operations. ...

March 27, 2026 · 4 min

Python Cheat Sheet 2026 — Syntax, Data Structures, and Common Patterns

Bookmark this page. Use Ctrl+F (or Cmd+F on Mac) to find what you need. This cheat sheet covers Python syntax from basics to advanced patterns. Try examples at pythontutor.com. Last updated: March 2026 Variables and Types name = "Alex" # str age = 25 # int height = 1.75 # float is_active = True # bool nothing = None # NoneType Type Example Notes int 42 No size limit float 3.14 64-bit decimal str "hello" Immutable bool True, False Capitalized None None Null equivalent list [1, 2, 3] Mutable, ordered tuple (1, 2, 3) Immutable, ordered dict {"a": 1} Key-value pairs set {1, 2, 3} Unique values, unordered Type Conversions int("42") # 42 float("3.14") # 3.14 str(42) # "42" list((1, 2, 3)) # [1, 2, 3] tuple([1, 2, 3]) # (1, 2, 3) set([1, 1, 2]) # {1, 2} bool(0) # False bool("") # False bool([]) # False bool("hello") # True Strings name = "Alex" f"Hello {name}" # f-string: Hello Alex f"Age: {age + 1}" # f-string with expression f"{price:.2f}" # format: 9.99 f"{name!r}" # repr: 'Alex' f"{num:,}" # thousands separator: 1,000,000 f"{value:>10}" # right-align, width 10 f"{value:<10}" # left-align, width 10 # Common methods "hello".upper() # "HELLO" "HELLO".lower() # "hello" "hello world".title() # "Hello World" " hello ".strip() # "hello" "hello world".split() # ["hello", "world"] "hello world".split("o") # ["hell", " w", "rld"] ", ".join(["a", "b", "c"]) # "a, b, c" "hello".replace("l", "r") # "herro" "hello".startswith("he") # True "hello".endswith("lo") # True "hello world".find("world") # 6 (-1 if not found) "hello world".count("l") # 3 "42".isdigit() # True # Multi-line strings text = """ First line Second line """ # Raw strings (no escape processing) path = r"C:\Users\name\folder" Lists nums = [1, 2, 3, 4, 5] # Access nums[0] # 1 (first) nums[-1] # 5 (last) nums[1:3] # [2, 3] (slice) nums[:3] # [1, 2, 3] (first 3) nums[2:] # [3, 4, 5] (from index 2) nums[::2] # [1, 3, 5] (every 2nd) nums[::-1] # [5, 4, 3, 2, 1] (reversed) # Modify nums.append(6) # add to end nums.insert(0, 0) # insert at index nums.extend([7, 8]) # add multiple nums.remove(3) # remove first occurrence nums.pop() # remove and return last nums.pop(0) # remove and return at index nums.sort() # sort in place nums.sort(reverse=True) # sort descending nums.reverse() # reverse in place nums.clear() # remove all # Functions len(nums) # length min(nums) # smallest max(nums) # largest sum(nums) # total sorted(nums) # new sorted list reversed(nums) # reversed iterator Dictionaries user = {"name": "Alex", "age": 25, "city": "Berlin"} # Access user["name"] # "Alex" (KeyError if missing) user.get("name") # "Alex" user.get("phone", "N/A") # "N/A" (default if missing) # Modify user["age"] = 26 # update user["email"] = "alex@mail.com" # add new key del user["city"] # delete key user.pop("age") # remove and return value # Iterate user.keys() # dict_keys(["name", "age", ...]) user.values() # dict_values(["Alex", 25, ...]) user.items() # dict_items([("name", "Alex"), ...]) for key, value in user.items(): print(f"{key}: {value}") # Merge (Python 3.9+) merged = dict1 | dict2 # dict2 values win on conflict Sets and Tuples # Sets — unique values, unordered colors = {"red", "green", "blue"} colors.add("yellow") colors.remove("red") # KeyError if missing colors.discard("red") # no error if missing a | b # union a & b # intersection a - b # difference a ^ b # symmetric difference # Tuples — immutable point = (10, 20) x, y = point # unpacking name, *rest = ("Alex", 25, "Berlin") # name="Alex", rest=[25, "Berlin"] Control Flow # if / elif / else if age < 18: print("minor") elif age < 65: print("adult") else: print("senior") # Ternary status = "adult" if age >= 18 else "minor" # for loop for item in items: print(item) for i in range(5): # 0, 1, 2, 3, 4 for i in range(2, 10): # 2, 3, ..., 9 for i in range(0, 10, 2): # 0, 2, 4, 6, 8 for i, item in enumerate(items): # index + value print(f"{i}: {item}") for a, b in zip(list1, list2): # parallel iteration print(a, b) # while loop while count > 0: count -= 1 # break / continue for item in items: if item == "skip": continue # skip this iteration if item == "stop": break # exit loop Pattern Matching (Python 3.10+) match status_code: case 200: print("OK") case 404: print("Not Found") case 500: print("Server Error") case _: print(f"Unknown: {status_code}") # Match with destructuring match point: case (0, 0): print("Origin") case (x, 0): print(f"On x-axis at {x}") case (0, y): print(f"On y-axis at {y}") case (x, y): print(f"Point at ({x}, {y})") # Match with guards match user: case {"role": "admin", "name": name}: print(f"Admin: {name}") case {"role": "user", "name": name} if name != "blocked": print(f"User: {name}") Comprehensions # List comprehension squares = [x**2 for x in range(10)] evens = [x for x in nums if x % 2 == 0] pairs = [(x, y) for x in range(3) for y in range(3)] # Dict comprehension word_lengths = {word: len(word) for word in words} filtered = {k: v for k, v in data.items() if v > 0} # Set comprehension unique_lengths = {len(word) for word in words} # Generator expression (lazy, memory-efficient) total = sum(x**2 for x in range(1000000)) Functions # Basic function def greet(name): return f"Hello {name}" # Default parameters def greet(name="World"): return f"Hello {name}" # *args and **kwargs def func(*args, **kwargs): print(args) # tuple of positional args print(kwargs) # dict of keyword args # Lambda double = lambda x: x * 2 sorted(users, key=lambda u: u["age"]) # Type hints (Python 3.10+) def greet(name: str) -> str: return f"Hello {name}" def process(items: list[int]) -> dict[str, int]: return {"sum": sum(items), "count": len(items)} Classes class User: def __init__(self, name: str, age: int): self.name = name self.age = age def greet(self) -> str: return f"Hi, I'm {self.name}" def __repr__(self) -> str: return f"User({self.name!r}, {self.age})" user = User("Alex", 25) # Dataclass (Python 3.7+) — auto-generates __init__, __repr__, __eq__ from dataclasses import dataclass @dataclass class User: name: str age: int city: str = "Unknown" # Inheritance class Admin(User): def __init__(self, name, age, level): super().__init__(name, age) self.level = level Error Handling try: result = 10 / 0 except ZeroDivisionError: print("Cannot divide by zero") except (ValueError, TypeError) as e: print(f"Error: {e}") else: print("Success") # runs if no exception finally: print("Always runs") # cleanup # Raise an exception raise ValueError("Invalid input") File I/O # Read entire file with open("file.txt", "r") as f: content = f.read() # Read lines with open("file.txt", "r") as f: lines = f.readlines() # list of lines # or for line in f: print(line.strip()) # Write with open("file.txt", "w") as f: # overwrite f.write("Hello\n") with open("file.txt", "a") as f: # append f.write("More text\n") # JSON import json data = json.loads('{"name": "Alex"}') # parse string text = json.dumps(data, indent=2) # to string with open("data.json", "r") as f: data = json.load(f) # parse file with open("data.json", "w") as f: json.dump(data, f, indent=2) # write file Async / Await import asyncio async def fetch_data(url: str) -> str: # simulate async work await asyncio.sleep(1) return f"Data from {url}" # Run async function async def main(): result = await fetch_data("https://api.example.com") print(result) asyncio.run(main()) # Run tasks in parallel async def main(): results = await asyncio.gather( fetch_data("https://api1.example.com"), fetch_data("https://api2.example.com"), ) print(results) # both complete in ~1 second, not 2 Common Built-in Functions Function Description Example len(x) Length len([1,2,3]) → 3 range(n) Sequence 0..n-1 range(5) → 0,1,2,3,4 enumerate(x) Index + value enumerate(["a","b"]) zip(a, b) Pair elements zip([1,2], ["a","b"]) map(fn, x) Apply function map(str, [1,2,3]) filter(fn, x) Filter elements filter(bool, [0,1,"",2]) any(x) True if any truthy any([False, True]) → True all(x) True if all truthy all([True, True]) → True sorted(x) New sorted list sorted([3,1,2]) → [1,2,3] reversed(x) Reversed iterator list(reversed([1,2,3])) isinstance(x, type) Type check isinstance(42, int) → True type(x) Get type type(42) → <class 'int'> dir(x) List attributes dir([]) help(x) Show docs help(str.split) Virtual Environments python -m venv .venv # create source .venv/bin/activate # activate (macOS/Linux) .venv\Scripts\activate # activate (Windows) pip install requests # install package pip freeze > requirements.txt # save dependencies pip install -r requirements.txt # install from file deactivate # deactivate Common Mistakes Mutable default arguments — def add(item, items=[]) shares the same list across all calls. Use def add(item, items=None) and items = items or [] inside the function. ...

March 22, 2026 · 7 min

How to Build Your First AI Coding Agent (Step by Step)

In the previous article, we learned what AI coding agents are. Now let’s build one. Not a toy demo. A real agent that reads your code, finds problems, fixes them, runs tests, and commits the result. You will understand how agents work from the inside. We will use Python and the Anthropic SDK (Claude API). The concepts apply to any AI provider. What We Are Building A simple agent that: Reads a Python file Sends it to Claude with instructions to fix linting errors Writes the fixed code back to the file Runs the linter to verify the fix If it still fails — tries again (up to 3 attempts) Commits the result with git This is the same loop that Claude Code and Copilot Agent use internally — just smaller and simpler. ...

March 16, 2026 · 8 min