Chapter 4: Functions Flashcards

1
Q

A general process for solving a category of problems.

A

algorithm

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

A value provided to a function when the function is called. This value is assigned to the corresponding parameter in the function.

A

argument

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

The sequence of statements inside a function definition.

A

body

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

Using an expression as part of a larger expression, or a statement as part of a larger statement.

A

composition

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

Pertaining to a program that does the same thing each time it runs, given the same inputs.

A

deterministic

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

The syntax for calling a function in another module by specifying the module name followed by a period and the function name.

A

dot notation

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

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

A

flow of execution

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

A function that returns a value.
Value needs to be printed or saved to variable in a script. Displays in interactive mode.

A

fruitful function

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

A named sequence of statements that performs some useful operation. May or may not take arguments and may or may not produce a result.

A

function

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

A statement that executes a function. It consists of the function name followed by an argument list.

A

function call

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

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

A

function definition

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

A value created by a function definition. The name of the function is a variable that refers to it.

A

function object

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

The first line of a function definition.

A

header

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

A statement that reads a module file and creates a module object.

A

import statement

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

A value created by an import statement that provides access to the data and code defined in a module.

A

module object

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

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

A

parameter

17
Q

Pertaining to a sequence of numbers that appear to be random, but are generated by a deterministic program.

A

pseudorandom

18
Q

The result of a function. If a function call is used as an expression, it’s the value of the expression.
Saved into a variable for use outside the function

A

return value

19
Q

A function that does not return a value.

A

void function

20
Q

built-in function that returns smallest value
(strings: a < z)

A

min function
min()

21
Q

built-in function that returns largest value
(strings: z > a)

A

max function
max()

22
Q

built-in function that returns number of items in object
eg. sequence (string,list) or collection

A

length function
len()

23
Q

Sequence types (7)

A

 strings
 unicode strings
 lists
 tuples
 bytearrays
 buffers
 xrange objects

24
Q

ordered sequence of items that is referred to by a single name, such that any given item within it can be specified by
using that name along with an index value that selects that item
uses [] brackets

A

list

25
Q

function that generates random value between 0.0 and 1.0 (excluded)

A

random function
random.random()

26
Q

function that generates random value between low and high parameters (included)

A

randint function
random.randint(1,10)

27
Q

function that selects an element from a given sequence at random
(eg. string or list)

A

choice function
random.choice(string/list)

28
Q

end function in interactive mode

A

empty line

29
Q

method to embed single quotes within string

A

triple quotes
“"”I’m a lumberjack and I’m ok”””

30
Q

take a complex process and break it down into a set of simpler functions.
aka functions calling other functions

A

functional decomposition