PCEP study materials
PCEP study resources

PCEP key terms

PCEP · Get comfortable with the vocabulary.

Interpreter

A program that reads source code and executes it directly, translating it statement by statement at runtime rather than producing a separate compiled executable file first.

Related: Variable, Keyword
Variable

A named reference that points to a value stored in memory. In Python you create one by assigning a value with the equals sign; no type declaration is required.

Related: Identifier, Type casting
Identifier

A name you give to a variable, function, class, or module. It must start with a letter or underscore, may contain digits, and cannot be a keyword.

Related: Variable, Keyword
Keyword

A word reserved by the Python language for a fixed purpose, such as if, for, def, or None. You cannot use it as an identifier.

Related: Identifier
Type casting

Converting a value from one data type to another using constructor functions such as int(), float(), or str(). Some conversions succeed silently while others raise an error at runtime.

Related: Exception, Variable
Operator precedence

The rules that decide which operator in an expression is evaluated first. Multiplication and division bind tighter than addition and subtraction, and parentheses override the default order.

Related: Modulo operator, Floor division
Floor division

The // operator, which divides two numbers and rounds the result down to the nearest whole number. With negative operands it rounds toward negative infinity, not toward zero.

Related: Modulo operator, Operator precedence
Modulo operator

The % operator, which returns the remainder left after integer division. It is often used to test whether a number is even or odd.

Related: Floor division
Truthiness

The rule that any object can be tested as a condition. Empty collections, zero numbers, None, and empty strings count as false; most other values count as true.

Related: if-elif-else, while loop
Escape sequence

A backslash followed by a character inside a string literal that stands for a special character, such as \n for a newline or \t for a tab.

if-elif-else

A conditional block that runs one of several branches. Python tests each condition in order and executes only the first branch whose condition is true.

Related: Truthiness, while loop
while loop

A loop that repeats a block as long as its condition remains true. The condition is checked before each pass, so the body may never run at all.

Related: for loop, break
for loop

A loop that visits each item of an iterable, such as a list, string, or range, and runs the body once per item.

Related: while loop, range()
range()

A built-in function that produces a sequence of integers. It accepts a stop value, or start and stop, plus an optional step, and never includes the stop value.

Related: for loop
break

A statement that immediately ends the innermost loop, skipping any remaining iterations and the loop's else block if one is present.

Related: continue, Loop else clause
continue

A statement that skips the rest of the current loop iteration and jumps straight to the next one, without ending the loop itself.

Related: break
Loop else clause

An optional else block attached to a for or while loop. It runs only when the loop finished normally, not when the loop was exited with break.

Related: break, while loop
List

An ordered, mutable collection written with square brackets. It can hold items of mixed types, allows duplicates, and supports indexing, slicing, and many in-place methods.

Related: Tuple, Indexing
Tuple

An ordered, immutable collection written with parentheses. Once created it cannot be changed, and it is often used to return several values from a function.

Related: List, Mutability
Dictionary

A mutable collection of key-value pairs written with curly braces. Keys must be unique and hashable; values can be any object. Lookup is done by key, not by position.

Related: Set, List
Set

An unordered, mutable collection of unique hashable items written with curly braces or set(). Duplicates are removed, and sets support union, intersection, and difference.

Related: Dictionary, Mutability
Indexing

Accessing a single item of a sequence by its position in square brackets. Python counts from zero, and negative indexes count backward from the end.

Related: Slicing, List
Slicing

Extracting a subsequence with the start:stop:step syntax. The start is included, the stop is excluded, and omitted values default to the beginning, the end, and a step of one.

Related: Indexing, List
Mutability

The property of an object that allows its contents to be changed after creation. Lists, dictionaries, and sets are mutable; tuples, strings, and numbers are not.

Related: List, Tuple
List comprehension

A compact expression that builds a new list by applying an operation to each item of an iterable, optionally keeping only items that satisfy an if condition.

Related: List, for loop
Membership operator

The in and not in operators, which test whether a value appears in a collection or a substring occurs in a string, returning True or False.

Related: Set, List
Function definition (def)

A block introduced by the def keyword that names a function, lists its parameters, and contains the code that runs when the function is called.

Related: Parameter and argument, Default parameter
Parameter and argument

A parameter is the name listed in a function definition; an argument is the actual value passed in when the function is called.

Related: Function definition (def), Default parameter
Default parameter

A parameter given a value in the function definition. If the caller omits that argument the default is used; defaults must come after parameters that have none.

Related: Parameter and argument, Function definition (def)
Scope

The region of a program where a name can be accessed. Python resolves names through local, enclosing, global, and built-in scopes, in that order.

Related: Function definition (def)
Exception

An event that interrupts normal execution, such as dividing by zero or converting an invalid string. Unhandled exceptions stop the program and print a traceback.

Related: try-except-finally, raise statement
try-except-finally

A block for handling errors: try holds risky code, except catches matching exceptions, and the optional finally always runs whether or not an error occurred.

Related: Exception, raise statement
raise statement

A statement that deliberately triggers an exception, either re-raising the current one or creating a new one with a message.

Related: Exception, try-except-finally
open()

A built-in function that opens a file and returns a file object used for reading or writing. It takes a path plus an optional mode and encoding.

Related: File mode, with statement
File mode

A short string passed to open() that says how the file is used: r for reading, w for writing and truncating, a for appending, b for binary, + for updating.

Related: open(), with statement
with statement

A context manager block that opens a file, runs its body, and closes the file automatically afterwards, even if an exception is raised inside.

Related: open(), File mode
import statement

The statement that loads a module and binds it to a name, giving access to its functions, classes, and variables through dot notation.

Related: from-import statement, __name__ guard
from-import statement

A form of import that brings specific names from a module directly into the current namespace, optionally renaming them with the as keyword.

Related: import statement
__name__ guard

The idiom if name == "main": used to run code only when the file is executed directly, not when it is imported as a module.

Related: import statement