Skip to content
BetaDE

Look it up

Glossary

Every term in one sentence – with a small example you can run and change right away.

Algorithm

An exact step-by-step set of instructions that solves a problem – for example searching or sorting.

numbers = [5, 2, 8]
print(sorted(numbers))
To the lesson →

Bug / debugging

A bug is a mistake in a program; debugging means finding and fixing it – e.g. with “Steps” in the editor.

total = 0
for i in range(1, 4):
    total += i
    print("So far:", total)

Class

A blueprint for your own objects with data and abilities.

class Dog:
    def bark(self):
        print("Woof!")


Dog().bark()
To the lesson →

Comparison

Compares two values and gives True or False: == != < > <= >=

print(3 == 3, 3 != 4, 2 >= 5)
To the lesson →

Condition (if)

Runs code only when something is true.

points = 7
if points > 5:
    print("good")
To the lesson →

Data type

The kind of a value: whole number (int), decimal (float), text (str), truth value (bool) …

print(type(3), type(3.5), type("Hi"), type(True))
To the lesson →

Dictionary

A dictionary of key–value pairs in curly braces.

ages = {"Ana": 12, "Ben": 13}
print(ages["Ben"])
To the lesson →

Error (exception)

When Python can't do something, it stops with an error message – for example NameError or ZeroDivisionError.

try:
    print(10 / 0)
except ZeroDivisionError:
    print("You can't divide by zero!")
To the lesson →

f-string

A string where you insert values with {}.

name = "Mia"
print(f"Hello {name}!")
To the lesson →

File

With open() you read and write files – with closes them again automatically.

with open("test.txt", "w") as f:
    f.write("Hello")
print(open("test.txt").read())
To the lesson →

Function

Your own named command, built with def, that you can use again and again.

def greet(name):
    print("Hello", name)


greet("Tom")
To the lesson →

Indentation

The spaces at the start of a line show what belongs to an if, loop or function (usually 4).

for i in range(2):
    print("inside")
print("outside")
To the lesson →

Index

The position in a list or string – counting starts at 0, -1 is the last element.

word = "Python"
print(word[0], word[-1])
To the lesson →

input()

Asks for something and returns the input as text.

# name = input("What is your name? ")
print("input() waits for you to type something")
To the lesson →

Interpreter

The program that checks Python code and runs it step by step – at Codelix it runs in your browser.

import sys
print(sys.version.split()[0])

JSON

A text format for data that programs use to store and exchange lists and dictionaries.

import json
print(json.dumps({"level": 3, "active": True}))
To the lesson →

List

Many values in order, in square brackets. The first one has index 0.

animals = ["dog", "cat"]
animals.append("mouse")
print(animals[0], len(animals))
To the lesson →

List comprehension

Building a list in one line.

print([n * n for n in range(5)])
To the lesson →

Loop

Repeats code – for a fixed number of times, while as long as something holds.

for i in range(3):
    print("Round", i)
To the lesson →

Module

A ready-made toolbox you bring in with import.

import random
print(random.randint(1, 6))
To the lesson →

Object

A thing built from a blueprint (class).

class Ball:
    def __init__(self, colour):
        self.colour = colour


b = Ball("red")
print(b.colour)
To the lesson →

Parameter

A value you pass into a function.

def double(number):
    return number * 2


print(double(21))
To the lesson →

range()

Creates number sequences for loops. range(3) gives 0, 1, 2.

print(list(range(1, 6)))
To the lesson →

Recursion

A function calls itself with a smaller problem – until it reaches a base case.

def countdown(n):
    if n == 0:
        return
    print(n)
    countdown(n - 1)


countdown(3)
To the lesson →

return

Gives a result back from a function.

def summe(a, b):
    return a + b


print(summe(2, 3))
To the lesson →

Set

A collection where every value appears only once.

print(set([1, 2, 2, 3, 3]))
To the lesson →

Tuple

Like a list, but unchangeable and with round brackets – good for pairs of values.

punkt = (3, 7)
x, y = punkt
print(x + y)
To the lesson →

Variable

A name for a value – like a labelled box.

age = 12
print(age)
To the lesson →