Skip to main content

Section 5.13 Glossary

Glossary Glossary

compound statement.
A statement that consists of two parts:
  1. header - which begins with a keyword determining the statement type, and ends with a colon.
  2. body - containing one or more statements indented the same amount from the header.
The syntax of a compound statement looks like this:
keyword expression:
    statement
    statement
    ...
header line.
The first part of a compound statement. A header line begins with a keyword and ends with a colon (:)
body.
The second part of a compound statement. The body consists of a sequence of statements all indented the same amount from the beginning of the header. The standard amount of indentation used within the Python community is 4 spaces.
function.
A named sequence of statements that performs some useful operation. Functions may or may not take parameters and may or may not produce a result.
function definition.
A statement that creates a new function, specifying its name, parameters, and the statements it executes.
function invocation.
The act of calling a defined function, by referring to it’s name followed by parentheses.
global variable.
A variable defined at the top level, not inside any function.
local variable.
A variable defined inside a function. A local variable can only be used inside its function. Parameters of a function are also a special kind of local variable.
lifetime.
Variables and objects have lifetimes β€” they are created at some point during program execution, and will be destroyed at some time. In python, objects live as long as there is some variable pointing to it, or it is part of some other compound object, like a list or a dictionary. In python, local variables live only until the function finishes execution.
docstrings.
Similar to comments, docstrings are messages from the programmer to help another person understand what that function is doing. Indicated by three quotation marks.
listener function.
A function that acts on end user input, such as key presses or clicks.
open.
You must open a file before you can read its contents.
close.
When you are done with a file, you should close it.
read.
Will read the entire contents of a file as a string. This is often used in an assignment statement so that a variable can reference the contents of the file.
readline.
Will read a single line from the file, up to and including the first instance of the newline character.
readlines.
Will read the entire contents of a file into a list where each line of the file is a string and is an element in the list.
write.
Will add characters to the end of a file that has been opened for writing.
You have attempted of activities on this page.