Python Glossary: 10 Core Terms with Examples
Review ten Python fundamentals with short examples. Change a value and predict the output before running the code. Examples use Python 3.
Studio01 · 2026-10-24
Variable
A name bound to a value so you can refer to it later. Assignment in Python does not permanently fix the variable's type.
count = 2
count = count + 1
print(count) # 3String
A type for text. An f-string makes it easy to insert a value into a readable message.
name = "Mika"
print(f"Hello, {name}!") # Hello, Mika!List
An ordered collection you can change. Use a list when items need to be added, removed, or replaced.
scores = [7, 9]
scores.append(8)
print(scores) # [7, 9, 8]Tuple
An ordered collection whose item references cannot be replaced. A tuple may still contain mutable objects.
point = (3, 5)
x, y = point
print(x + y) # 8Dictionary
A mapping from unique, hashable keys to values. Look up a value by its key.
book = {'title': 'Python', 'pages': 120}
print(book['pages']) # 120Set
A collection of distinct, hashable elements. Useful for removing duplicates and checking membership; iteration order is not guaranteed.
tags = {'python', 'books', 'python'}
print(len(tags)) # 2
print('books' in tags) # TrueFor loop
Visits items from an iterable one at a time. The end of a range is excluded.
for number in range(1, 4):
print(number) # 1, then 2, then 3Function
A reusable block defined with def. Parameters accept inputs; return sends a result to the caller.
def double(value):
return value * 2
print(double(6)) # 12Boolean
True or False represents whether a condition holds. A comparison expression can be used in an if statement.
has_book = True
if has_book:
print("Start reading")Exception
An error raised while code runs. Use try/except to handle a failure you can anticipate; avoid silently swallowing overly broad exceptions.
try:
pages = int("120")
except ValueError:
print("Could not convert to a number")
else:
print(pages) # 120