Functions Flashcards

1
Q

(True/False) The function body is referred to as its suite.

A

False. The function body is referred to as its block.

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

(True/False) A function’s local variables exist after the function returns to its caller.

A

False. A function’s local variables exist until the function returns to its caller.

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

(Fill-In) A function with multiple parameters specifies them in a(n) ________.

A

comma-separated list.

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

(True/False) When defining a function in IPython interactive mode, pressing Enter on a blank line causes IPython to display another continuation prompt so you can continue defining the function’s block

A

False. When defining a function in IPython interactive mode, pressing Enter on a blank line terminates the function definition.

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

(Fill-In) The element of chance can be introduced into computer applications using module _________.

A

random.

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

(Fill-In) The random module’s __________ function enables reproducibility of random sequences.

A

seed.

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

(Fill-In) A(n) _______ defines related functions, data and classes. A(n) _________ groups related modules.

A

module, package.

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

(Fill-In) Every Python source code (.py) file you create is a(n) ______.

A

module.

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

(True/False) In IPython interactive mode, to view a list of identifiers defined in a module, type the module’s name and a dot (.) then press Enter.

A

False. Press Tab, not Enter.

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

(True/False) Python does not have constants.

A

True.

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

(True/False) When an argument with a default parameter value is omitted in a function call, the interpreter automatically passes the default parameter value in the call

A

True

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

(True/False) Parameters with default parameter values must be the leftmost arguments in a function’s parameter list.

A

False. Parameters with default parameter values must appear to the right of parameters that do not have defaults.

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

(True/False) You must pass keyword arguments in the same order as their corresponding parameters in the function definition’s parameter list.

A

False. The order of keyword arguments does not matter.

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

(Fill-In) To define a function with an arbitrary argument list, specify a parameter of the form ________.

A

*args (again, the name args is used by convention, but is not required).

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

(Fill-In) An identifier’s ________ describes the region of a program in which the identifier’s value can be accessed.

A

scope.

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

(True/False) Once a code block terminates (e.g., when a function returns), all identifiers defined in that block “go out of scope” and can no longer be accessed.

A

True.

17
Q

(True/False) You must always import all the identifiers of a given module.

A

False. You can import only the identifiers you need by using a from…import statement.

18
Q

(Fill-In) The built-in function ______ returns an object’s unique identifier.

A

id.

19
Q

(True/False) Attempts to modify mutable objects create new objects.

A

False. This is true for immutable objects.

20
Q

(Fill-In) The stack operations for adding an item to a stack and removing an item from a stack are known as ______ and ______, respectively.

A

push, pop

21
Q

(Fill-In) A stack’s items are removed in order.

A

last-in, first-out (LIFO).

22
Q

(Discussion) Why do we often work with a sample rather than the full population?

A

Because often, the full population is unmanageably large.

23
Q

(True/False) An advantage of the population variance over the population standard deviation is that its units are the same as the sample values’ units.

A

False. This an advantage of population standard deviation over population variance.