Chapter 4 Flashcards

1
Q

argument

A

A value provided to a function when the function is called. This value is assigned to the corresponding parameter in the function. The argument can be the result of an expression which may involve operators, operands and calls to other fruitful functions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

body

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

compound statement

A

A statement that consists of two parts:

header - which begins with a keyword determining the statement type, and ends with a colon.
body - containing one or more statements indented the same amount from the header.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

docstring

A

If the first thing in a function body is a string (or, we’ll see later, in other situations too) that is attached to the function as its __doc__ attribute, and can be used by tools like PyScripter.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

flow of execution

A

The order in which statements are executed during a program run.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

frame

A

A box in a stack diagram that represents a function call. It contains the local variables and parameters of the function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

function

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

function call

A

A statement that executes a function. It consists of the name of the function followed by a list of arguments enclosed in parentheses.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

function composition

A

Using the output from one function call as the input to another.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

function definition

A

A statement that creates a new function, specifying its name, parameters, and the statements it executes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

fruitful function

A

A function that returns a value when it is called.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

header line

A

The first part of a compound statement. A header line begins with a keyword and ends with a colon (:)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

import statement

A

A statement which permits functions and variables defined in another Python module to be brought into the environment of another script. To use the features of the turtle, we need to first import the turtle module.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

lifetime

A

Variables and objects have lifetimes — they are created at some point during program execution, and will be destroyed at some time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

local variable

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

parameter

A

A name used inside a function to refer to the value which was passed to it as an argument.

17
Q

refactor

A

A fancy word to describe reorganizing our program code, usually to make it more understandable. Typically, we have a program that is already working, then we go back to “tidy it up”. It often involves choosing better variable names, or spotting repeated patterns and moving that code into a function.

18
Q

stack diagram

A

A graphical representation of a stack of functions, their variables, and the values to which they refer.

19
Q

traceback

A

A list of the functions that are executing, printed when a runtime error occurs. A traceback is also commonly refered to as a stack trace, since it lists the functions in the order in which they are stored in the runtime stack.

20
Q

void function

A

The opposite of a fruitful function: one that does not return a value. It is executed for the work it does, rather than for the value it returns.