DE EN

Python Lexicon

The most comprehensive Python glossary for beginners and advanced learners

50+
Terms
8
Essentials
4
Categories
2
Languages

Understanding Python Terms

Variable, Dictionary, List Comprehension, Decorator — sounds like gibberish? It's not. This lexicon explains all important Python terms so everyone can understand them. No prior knowledge needed.

Each term contains a short definition, a detailed explanation, an everyday analogy, and a concrete code example — for different learning styles.

Start with the 8 most important terms or use the alphabetical navigation.
TOP 8 — START HERE

The Most Important Terms

These 8 terms form the foundation for everything else. They are the basis on which you will understand all other concepts.

A 2 Terms

Argument

A value you pass to a function. print("Hello") — "Hello" is the argument. Functions can take any number of arguments.

def begruessen(name): print(f"Hello {name}!") begruessen("Max") # "Max" is the argument
Beginner

Attribut

A variable that belongs to an object. In a class, attributes are the object's data: self.name = "Max" — name is an attribute.

class Hund: def __init__(self, name): self.name = name # Attribute bello = Hund("Bello") print(bello.name) # "Bello"
Intermediate

B 3 Terms

Bool / Boolean

A boolean value: either True or False. Essential for conditions and comparisons. Everything in Python is "truthy" or "falsy".

ist_aktiv = True hat_geld = False if ist_aktiv and not hat_geld: print("Aktiv, aber pleite") print(bool(0)) # False print(bool("Hello")) # True
Beginner

break

Breaks a loop immediately. When a condition is met, Python jumps out of the loop — useful for searches and early exits.

for i in range(10): if i == 5: break # End loop print(i) # Output: 0, 1, 2, 3, 4
Beginner

Built-in Funktion

A function that Python provides out of the box: print(), len(), input(), range(), type() — available without import.

text = "Hello World" print(len(text)) # 10 print(type(text)) print(max(3, 7, 2)) # 7 print(sum([1,2,3])) # 6
Beginner

C 3 Terms

class

Defines a blueprint for objects. With class Dog: you create a template from which you can generate any number of dog objects. Basis of object orientation.

class Katze: def __init__(self, name): self.name = name def miauen(self): return f"{self.name} sagt Miau!" mimi = Katze("Mimi") print(mimi.miauen())
Intermediate

continue

Skips the rest of the current loop round and immediately starts the next one. Unlike break, the loop doesn't completely abort.

for i in range(1, 6): if i == 3: continue # Skip 3 print(i) # Output: 1, 2, 4, 5
Beginner

Comprehension

Compact syntax for lists, dictionaries, and sets: [x*2 for x in list] — elegant, fast, and pythonic. One line instead of several.

zahlen = [1, 2, 3, 4, 5] quadrate = [x**2 for x in zahlen] gerade = [x for x in zahlen if x % 2 == 0] print(quadrate) # [1, 4, 9, 16, 25] print(gerade) # [2, 4]
Intermediate

D 4 Terms

Decorator (@)

A function that "wraps" and extends another function. @staticmethod or custom decorators — an advanced concept for clean code.

import time def timer(func): def wrapper(*args): start = time.time() result = func(*args) print(f"Dauer: {time.time()-start:.4f}s") return result return wrapper @timer def langsame_funktion(): time.sleep(1)
Advanced

Dictionary (dict)

Stores key-value pairs: {"name": "Max", "age": 16}. Fast access via the key. Perfect for structured data and JSON.

nutzer = { "name": "Lisa", "alter": 17, "stadt": "Wien" } print(nutzer["name"]) nutzer["email"] = "lisa@mail.at" print(nutzer.get("telefon", "Nicht angegeben"))
Intermediate

Docstring

A documentation string directly under a function or class. With triple quotes: """Description""". Displayed by tools like help().

def flaeche(breite, hoehe): """Berechnet die Flaeche. Args: breite: Breite in cm hoehe: Hoehe in cm Returns: Flaeche in cm2 """ return breite * hoehe
Beginner

Dunder / Magic Method

Methods with double underscores: __init__, __str__, __len__. They define how objects behave — e.g. what happens when you call print(object).

class Buch: def __init__(self, titel): self.titel = titel def __str__(self): return f"Buch: {self.titel}" def __len__(self): return len(self.titel) b = Buch("Python") print(str(b)) # Buch: Python print(len(b)) # 6
Advanced

E 4 Terms

elif

"Else if" — Checks another condition when the if was false. You can use as many elifs as you want to cover multiple cases.

note = 2 if note == 1: print("Sehr gut!") elif note == 2: print("Gut!") elif note == 3: print("Befriedigend") else: print("Mehr Uebung noetig")
Beginner

else

Catches all cases not covered by if or elif. Optional — but often useful for default behavior or error messages.

alter = 15 if alter >= 16: print("Du darfst Moped fahren") else: print(f"Noch {16 - alter} Jahre warten")
Beginner

enumerate()

Returns both index AND value in a loop: for i, name in enumerate(list):. Practical when you need the position of each element.

fruechte = ["Apfel", "Banane", "Kirsche"] for index, frucht in enumerate(fruechte, start=1): print(f"{index}. {frucht}") # 1. Apfel # 2. Banane # 3. Kirsche
Beginner

Exception

An error that interrupts the normal program flow. With try/except you catch it and react — instead of the program crashing.

try: zahl = int(input("Zahl: ")) ergebnis = 100 / zahl print(ergebnis) except ValueError: print("Das war keine Zahl!") except ZeroDivisionError: print("Division durch Null!")
Intermediate

F 5 Terms

File I/O

Reading and writing files. with open("file.txt") as f: opens a file safely. Important for data storage and processing.

# Writing with open("notiz.txt", "w") as f: f.write("Hello World!\n") # Reading with open("notiz.txt", "r") as f: inhalt = f.read() print(inhalt)
Intermediate

float

A data type for decimal numbers: 3.14, -0.5, 2.0. Stored internally as a floating-point number — watch out for rounding errors in very precise calculations!

pi = 3.14159 preis = 19.99 print(f"Pi = {pi:.2f}") # Pi = 3.14 print(f"Preis: {preis} Euro") print(type(pi))
Beginner

for-Schleife

Repeats code for each element in a collection. The most common loop type in Python — elegant and easy to read.

namen = ["Anna", "Ben", "Clara"] for name in namen: print(f"Hello {name}!") # Mit range for i in range(1, 4): print(f"Runde {i}")
Beginner

f-string

Formatted string with built-in variables: f"Hello {name}". The modern, recommended way to format strings in Python.

name = "Max" alter = 16 note = 1.5 print(f"Hello {name}!") print(f"In 5 Jahren: {alter + 5}") print(f"Note: {note:.1f}") print("=" * 20)
Beginner

Funktion (def)

A named block of code that can be reused. Defined with def, optionally with parameters and return value via return.

def quadrat(zahl): return zahl ** 2 def begruessen(name, sprache="de"): if sprache == "de": return f"Hello {name}!" return f"Hello {name}!" print(quadrat(4)) print(begruessen("Lisa", "en"))
Beginner

G 2 Terms

Generator

A function with yield instead of return. It produces values "on demand" — memory-efficient for large data sets. Once exhausted, it's spent.

def zaehle_bis(n): for i in range(1, n + 1): yield i for zahl in zaehle_bis(5): print(zahl) # Memory efficient! quadrate = (x**2 for x in range(1000000))
Advanced

global

Makes a variable outside a function mutable. Often considered a "code smell" — better to pass values in and return them.

counter = 0 def erhoehe(): global counter counter += 1 print(f"Counter: {counter}") erhoehe() # Counter: 1 erhoehe() # Counter: 2
Intermediate

H 1 Term

Hash / Hashable

A value that has a fixed "identity number" and doesn't change. Strings and numbers are hashable (valid as dictionary keys), lists are not.

mein_set = {1, 2, 3} mein_set.add(4) # Not hashable (mutable) # liste = [1, 2] # my_set.add(list) # TypeError!
Advanced

I 5 Terms

if / elif / else

Conditional execution: When a condition is true, the code block is executed. The foundation for decisions in programs.

temperatur = 25 if temperatur > 30: print("Zu heiss!") elif temperatur > 20: print("Angenehm") else: print("Zu kalt")
Beginner

import

Loads external modules or libraries into your program: import random or from math import sqrt. Python has thousands of available modules.

import random import math from datetime import datetime wuerfel = random.randint(1, 6) wurzel = math.sqrt(16) jetzt = datetime.now() print(f"Wuerfel: {wuerfel}") print(f"Wurzel: {wurzel}")
Beginner

Index

The position of an element in a list. Python starts at 0: list[0] is the first element. Negative indices count from the end: list[-1] is the last.

farben = ["Rot", "Gruen", "Blau"] print(farben[0]) # Rot print(farben[-1]) # Blau print(farben[1:3]) # [Gruen, Blau] print(farben.index("Gruen")) # 1
Beginner

int

The data type for integers: 42, -7, 0. Python can handle arbitrarily large integers — without overflow like in other languages.

alter = 16 # Konvertierung text = "42" zahl = int(text) print(zahl + 8) # 50 print(type(alter)) print(10 // 3) # 3
Beginner

Iterable

An object that can be traversed element by element: lists, strings, dictionaries, sets. Everything that works in a for loop.

for char in "Python": print(char) for key in {"a": 1, "b": 2}: print(key) # Alles Iterables: String, Liste, Dict, Tuple, Set
Intermediate

J 2 Terms

join()

Joins list elements into a string: ",".join(["a", "b", "c"]) results in "a,b,c". A string method — the reverse of split().

woerter = ["Python", "ist", "toll"] satz = " ".join(woerter) print(satz) # Python ist toll print("a,b,c".split(",")) # [a, b, c]
Beginner

JSON

A universal data format for data exchange. Python can seamlessly convert JSON to dictionaries with json.load() and json.dump().

import json daten = {"name": "Max", "alter": 16} with open("daten.json", "w") as f: json.dump(daten, f, indent=2) with open("daten.json", "r") as f: geladen = json.load(f)
Intermediate

K 3 Terms

Key (Dictionary)

The "name" in a key-value pair. Must be unique and immutable (hashable). Strings and numbers are the most common key types.

nutzer = {"name": "Lisa", "alter": 17} print(list(nutzer.keys())) print(list(nutzer.values())) for key, value in nutzer.items(): print(f"{key}: {value}")
Beginner

Klasse (class)

Blueprint for objects. Packages data (attributes) and functions (methods) together. The basis of object-oriented programming in Python.

class Auto: def __init__(self, marke, farbe): self.marke = marke self.farbe = farbe def beschreibung(self): return f"Ein {self.farbe}es {self.marke}" mein_auto = Auto("VW", "blau") print(mein_auto.beschreibung())
Intermediate

*args / **kwargs

Receive any number of arguments: *args as a tuple, **kwargs as a dictionary. Flexible function signatures for advanced patterns.

def profil_anzeigen(**daten): for key, value in daten.items(): print(f"{key}: {value}") profil_anzeigen(name="Max", alter=16, stadt="Wien") # Any number of named arguments!
Advanced

L 4 Terms

Lambda

An anonymous, one-line function: square = lambda x: x**2. Compact for small operations — often used with map(), filter(), or sorted().

quadrat = lambda x: x ** 2 print(quadrat(5)) # 25 spieler = [{"name": "Anna", "punkte": 95}] spieler.sort(key=lambda s: s["punkte"])
Intermediate

len()

Returns the length of an object: number of elements in a list, characters in a string, entries in a dictionary. One of the most frequently used built-in functions.

text = "Hello World" zahlen = [1, 2, 3, 4, 5] print(len(text)) # 10 print(len(zahlen)) # 5 if len(zahlen) > 0: print("Liste hat Eintraege")
Beginner

Liste (list)

Ordered, mutable collection of values. Created with square brackets. The most important data structure in Python for almost all use cases.

aufgaben = ["Python", "CSS", "HTML"] aufgaben.append("JavaScript") print(aufgaben[0]) print(aufgaben[-1]) print(len(aufgaben)) for i, a in enumerate(aufgaben): print(f"{i+1}. {a}")
Beginner

Loop / Schleife

Repeats code multiple times. for for collections, while for conditional repetition. The most efficient way to automate repetitive tasks.

# for loop for i in range(5): print(i) # while loop zahl = 1 while zahl <= 5: print(zahl) zahl += 1 # Infinite loop with break while True: if input("Exit? ") == "Exit": break
Beginner

M 4 Terms

Methode

A function that belongs to an object. list.append("x") or string.upper() — called with a dot after the object.

text = "Hello World" print(text.upper()) print(text.replace("World", "Python")) zahlen = [3, 1, 4] zahlen.sort() print(zahlen) # [1, 3, 4]
Beginner

Modul

A Python file containing functions and classes. With import you load them into your program. Python has a huge ecosystem of modules.

# hilfen.py def durchschnitt(zahlen): return sum(zahlen) / len(zahlen) if __name__ == "__main__": print(durchschnitt([1, 2, 3])) # main.py import hilfen print(hilfen.durchschnitt([4, 5, 6]))
Beginner

Mutable / Immutable

Mutable: lists, dictionaries, sets. Immutable: strings, tuples, numbers. Mutable objects can still be changed after creation.

# Mutable liste = [1, 2, 3] liste.append(4) print(liste) # [1, 2, 3, 4] # Immutable text = "Hello" text = text.lower() # New object!
Intermediate

__main__

The entry point of a Python program. if __name__ == "__main__": ensures that code only runs when started directly — not on import.

# hilfen.py def addiere(a, b): return a + b if __name__ == "__main__": print(addiere(2, 3)) # main.py import hilfen # Der Test-Code oben laeuft NICHT!
Intermediate

N 2 Terms

None

Python's version of "nothing". A function without return automatically returns None. Useful to signal "no value yet".

def gruessen(name): print(f"Hello {name}!") # Kein return ergebnis = gruessen("Max") print(ergebnis) # None
Beginner

Namespace

A "namespace" where variable names are unique. Every module, function, and class has its own namespace — this prevents name collisions.

name = "Global" def funktion(): name = "Lokal" print(name) # Lokal funktion() print(name) # Global
Advanced

O 3 Terms

OOP

Object-oriented programming: Code is organized in objects that combine data and functions. Classes, inheritance, polymorphism — the basis of large programs.

class Tier: def __init__(self, name): self.name = name def laut(self): return "..." class Hund(Tier): def laut(self): return "Wuff!" bello = Hund("Bello") print(bello.laut()) # Wuff!
Intermediate

open()

Opens a file for reading or writing. Combined with with for safe file operations: with open("file.txt") as f: — closes automatically.

# Reading with open("datei.txt", "r") as f: inhalt = f.read() # Writing with open("datei.txt", "w") as f: f.write("Neuer Text") # Appending with open("log.txt", "a") as f: f.write("Neuer Eintrag\n")
Intermediate

Operator

Symbols for calculations and comparisons: +, -, *, /, ==, !=, >, and, or, not. The building blocks of all expressions in Python.

a = 10 b = 3 print(a + b) # 13 print(a // b) # 3 print(a % b) # 1 print(a > b) # True print(a == 10) # True
Beginner

P 5 Terms

Parameter

A placeholder in a function definition: def greet(name): — name is the parameter. When called, an argument is passed that fills the parameter.

def begruessen(name, sprache="de"): if sprache == "de": return f"Hello {name}!" return f"Hello {name}!" print(begruessen("Max")) print(begruessen("Lisa", "en"))
Beginner

pip

Python's package manager. Installs external libraries: pip install requests. The gateway to Python's huge ecosystem of over 400,000 packages.

# Paket installieren $ pip install requests # Alle installierten Pakete $ pip list # In virtueller Umgebung $ python -m venv venv $ source venv/bin/activate
Beginner

print()

Outputs text to the console. The first function every Python learner encounters. With sep and end you can customize the behavior.

name = "Max" alter = 16 print("Hello", name) print(f"Hello {name}!") print("a", "b", "c", sep="-") # a-b-c
Beginner

@property

Turns a method into a readable attribute. @name.setter allows controlled setting. Elegant for encapsulated class attributes.

class Kreis: def __init__(self, radius): self._radius = radius @property def flaeche(self): return 3.14159 * self._radius ** 2 k = Kreis(5) print(k.flaeche) # 78.54
Advanced

PyBuddy

Your project in the Python Classic course — an AI assistant that you expand chapter by chapter. From a simple chatbot to an interactive helper with file I/O.

# Your PyBuddy CLI project import pybuddy pybuddy.begruessen("Max")
Beginner

R 4 Terms

range()

Generates a sequence of numbers: range(5) → 0,1,2,3,4. range(2, 10, 2) → 2,4,6,8. The for loop's best friend for counting tasks.

# 0 bis 4 for i in range(5): print(i) # 1 bis 5 for i in range(1, 6): print(i) # Nur gerade for i in range(0, 10, 2): print(i)
Beginner

Rekursion

A function that calls itself. Always needs a termination condition, otherwise infinite loop. Elegant for tree structures and mathematical problems.

def fakultaet(n): if n <= 1: return 1 return n * fakultaet(n - 1) print(fakultaet(5)) # 120 # 5! = 5 * 4 * 3 * 2 * 1 = 120
Advanced

return

Returns a value from a function and ends it. Without return, a function returns None. The heart of data processing.

def addiere(a, b): return a + b def ist_gueltig(alter): if alter >= 18: return True return False print(addiere(5, 3)) # 8 print(ist_gueltig(20)) # True
Beginner

raise

Raises an exception yourself: raise ValueError("Invalid input"). Useful to detect errors early and give clear error messages.

def teilen(a, b): if b == 0: raise ValueError("Nicht durch Null!") return a / b try: print(teilen(10, 0)) except ValueError as e: print(f"Fehler: {e}")
Intermediate

S 6 Terms

self

Refers to the current object in a class. The first parameter of every method (except static). self.name accesses the object's attribute.

class Schueler: def __init__(self, name): self.name = name def vorstellen(self): return f"Ich bin {self.name}" max = Schueler("Max") print(max.vorstellen()) # Ich bin Max
Intermediate

Set

An unordered collection without duplicates. {1, 2, 3} or set(list). Perfect for set operations like union and intersection.

zahlen = {1, 2, 3, 3, 3} print(zahlen) # {1, 2, 3} a = {1, 2, 3} b = {3, 4, 5} print(a | b) # {1, 2, 3, 4, 5} print(a & b) # {3}
Intermediate

Slicing

Cutting out parts: list[0:3] → elements 0 to 2. text[::-1] → text reversed. One of Python's most elegant features.

text = "Python ist toll" zahlen = [0, 1, 2, 3, 4, 5] print(text[0:6]) # Python print(text[::-1]) # llot tsi nohtyP print(zahlen[1:4]) # [1, 2, 3] print(zahlen[::2]) # [0, 2, 4]
Beginner

String (str)

Text in Python: "Hello World". Immutable and extremely versatile. Methods like .upper(), .split(), .replace() make text processing easy.

name = "Python" print(name.upper()) print(name.replace("P", "J")) print(f"Ich lerne {name}") print(" hallo ".strip())
Beginner

SyntaxError

An error that occurs when Python's grammar is violated: forgotten colon, wrong indentation, missing bracket. The most common beginner error source.

# CORRECT def begruessen(name): return f"Hello {name}!" # ERROR: Forgotten colon def begruessen(name) return "Hello!" # SyntaxError: expected :
Beginner

@staticmethod / @classmethod

Methods that don't need self. @staticmethod is a normal function in a class. @classmethod receives the class itself (cls).

class Mathe: @staticmethod def addiere(a, b): return a + b print(Mathe.addiere(5, 3)) # 8
Advanced

T 4 Terms

try / except

Catches errors so the program doesn't crash. try: attempts something, except: reacts to the error. Optional with else and finally.

try: datei = open("daten.txt") inhalt = datei.read() except FileNotFoundError: print("Datei nicht gefunden!") inhalt = "Standardwert" finally: print("Wird immer ausgefuehrt")
Intermediate

Tupel (tuple)

Like a list, but immutable: (1, 2, 3). After creation, no elements can be added or removed. Safer for constant data.

koordinaten = (10, 20) farbe = (255, 128, 0) print(koordinaten[0]) # 10 x, y = koordinaten print(f"x={x}, y={y}") # Tupel sind immutable!
Beginner

type()

Returns the data type of a value: type(42)<class 'int'>. With isinstance() you check whether a value has a certain type.

name = "Lisa" alter = 16 print(type(name)) # <class str> print(type(alter)) # <class int> if type(alter) is int: print("Ganzzahl!")
Beginner

Type Hinting

Optional type annotations for better readability: def add(a: int, b: int) -> int:. Python doesn't enforce them, but IDEs and tools use them for better support.

from typing import List, Dict def summe(zahlen: List[int]) -> int: return sum(zahlen) print(summe([1, 2, 3])) # 6
Intermediate

V 3 Terms

Variable

A named storage box for data. The building block of every program. Python recognizes the data type automatically — no declaration needed.

name = "Max" alter = 16 # Mehrfachzuweisung x, y, z = 1, 2, 3 print(f"{name} ist {alter} Jahre alt")
Beginner

venv

Virtual Environment — an isolated Python workspace. Every project gets its own libraries. Prevents version conflicts between projects.

# Create virtual environment $ python -m venv venv # Activate $ venv\Scripts\activate # Windows $ source venv/bin/activate # Mac/Linux $ pip install requests
Intermediate

Vererbung

A class inherits attributes and methods from another: class Dog(Animal):. Avoids code repetition and enables specialization.

class Tier: def __init__(self, name): self.name = name class Hund(Tier): def laut(self): return "Wuff!" class Katze(Tier): def laut(self): return "Miau!" for tier in [Hund("Bello"), Katze("Mimi")]: print(f"{tier.name}: {tier.laut()}")
Intermediate

W 3 Terms

while-Schleife

Repeats code as long as a condition is true. Needs a termination condition, otherwise infinite loop. Good for an unknown number of repetitions.

antwort = "" while antwort != "ja": antwort = input("Nochmal? ") # Mit Zaehler countdown = 3 while countdown > 0: print(countdown) countdown -= 1 print("Los!")
Beginner

with-Statement

Ensures clean resource management: with open("file.txt") as f:. Closes the file automatically — even on errors. Cleaner and safer.

# Automatic closing with open("daten.txt", "r") as f: inhalt = f.read() # f is already closed here!
Intermediate

Walrus Operator (:=)

Assignment AND return in one step: if (n := len(text)) > 10:. Saves lines but can affect readability. Available since Python 3.8.

# Without walrus name = input("Name: ") while name != "exit": print(f"Hello {name}!") name = input("Name: ") # With walrus while (name := input("Name: ")) != "exit": print(f"Hello {name}!")
Advanced

Z 1 Term

zip()

Combines multiple lists pairwise: zip(names, ages)("Max", 16), ("Lisa", 17). Often used with for name, age in zip(...).

namen = ["Anna", "Ben"] noten = [1, 2] for name, note in zip(namen, noten): print(f"{name}: Note {note}") woerterbuch = dict(zip(namen, noten)) print(woerterbuch) # {Anna: 1, Ben: 2}
Intermediate