ShareYourGroupShareYourGroupPython

Python words explained: a beginner's glossary

Programming has its own vocabulary, and tutorials tend to use it without warning. This page explains the words you will meet in these lessons and in other people's explanations, in plain English, with a tiny example where one helps. The words are in alphabetical order.

A to C

Argument. A value you pass to a function when you call it. In print("hi"), the argument is "hi". Compare with parameter.

Assignment. Storing a value under a name with a single equals sign: age = 14.

Attribute. Something that belongs to an object and is reached with a dot, such as student.name.

Boolean (bool). A value that is either True or False. Comparisons such as 5 > 3 produce booleans.

Bug. A mistake in a program that makes it do the wrong thing. Finding and fixing bugs is called debugging.

Call. To run a function by writing its name followed by round brackets: len("cat").

Class. A pattern for making objects that share the same kind of data and actions. See lesson 21.

Comment. A note for human readers, starting with #. Python ignores it.

Comprehension. A one-line way to build a list, set or dictionary from a loop: [n * n for n in range(5)].

Concatenate. To join strings end to end with +: "sun" + "light" gives "sunlight".

Condition. An expression that is true or false, used by if and while.

D to I

Dictionary (dict). A collection that stores values under keys: {"tea": 10}. See lesson 14.

Docstring. A string in triple quotation marks at the top of a function that says what the function does.

Exception. Python's word for an error that happens while a program runs. An exception can be caught with try and except.

Expression. Any piece of code that works out to a value: 2 + 3, len(name), age >= 18.

Float. A number with a decimal point, such as 3.5.

Function. A named block of code that does one job. You define it with def and run it by calling it.

Immutable. Cannot be changed after it is made. Strings and tuples are immutable. Lists and dictionaries are not.

Import. To bring a module into your program so that you can use what it contains: import math.

Indentation. The spaces at the start of a line. In Python they show which lines belong to a block.

Index. The position number of an item in a string or list. Counting starts at 0.

Integer (int). A whole number, such as 42 or -7.

Interpreter. The program that reads your Python code and carries it out. When you "install Python", this is what you install.

Iterate. To go through the items of a collection one by one, usually with a for loop. Anything you can loop over is called an iterable.

K to P

Key. The name under which a value is stored in a dictionary.

Keyword. A word reserved by Python, such as if, for, def and return. Keywords cannot be used as variable names. Keyword argument is something different: an argument passed by name, as in print("a", end="").

List. An ordered, changeable collection in square brackets: [1, 2, 3].

Loop. Code that repeats. Python has for loops and while loops.

Method. A function that belongs to an object and is called with a dot: "hello".upper().

Module. A file of ready-made Python code that you can import, such as math or random.

Mutable. Can be changed in place. Lists, sets and dictionaries are mutable.

None. A special value meaning "nothing". A function with no return gives None.

Object. Any value in Python. Numbers, strings, lists and functions are all objects.

Operator. A symbol that works on values, such as +, == or and.

Parameter. A name in a function's definition that receives a value. In def greet(name):, the parameter is name. The value passed in a call is the argument.

R to Z

Return. To hand a result back from a function to the code that called it, with the return keyword.

Scope. The part of a program where a name can be seen. A variable made inside a function is in that function's local scope.

Slice. A piece of a string or list, taken with [start:stop].

Statement. One complete instruction, usually one line, such as x = 5 or print(x).

String (str). A piece of text inside quotation marks.

Syntax. The grammar of the language: where the colons, brackets and indents must go.

Traceback. The report Python prints when a program stops with an error. Read it from the last line. See the errors section.

Tuple. An ordered collection that cannot be changed, in round brackets: (3, 5).

Type. The kind of a value: int, float, str, list and so on. type(x) tells you the type of x.

Variable. A name that points to a value.

Words that sound alike

Several pairs of words confuse beginners because they describe two sides of one thing.

PairThe difference
parameter and argumentthe name in the def line; the value in the call
function and methodstands alone, len(x); belongs to a value, x.upper()
= and ==stores a value; compares two values
print and returnshows on the screen; hands back to the program
list and tuplechangeable; fixed
error and exceptioneveryday word; Python's own word for the same event

If a word you met is not here, the official glossary at docs.python.org lists every term used in Python's documentation, in more technical language.

This is an independent learning site. It is not connected with or approved by the Python Software Foundation. "Python" is a trademark of the Python Software Foundation and is used here only to name the language.