Functions Flashcards
(True/False) The function body is referred to as its suite.
False. The function body is referred to as its block.
(True/False) A function’s local variables exist after the function returns to its caller.
False. A function’s local variables exist until the function returns to its caller.
(Fill-In) A function with multiple parameters specifies them in a(n) ________.
comma-separated list.
(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
False. When defining a function in IPython interactive mode, pressing Enter on a blank line terminates the function definition.
(Fill-In) The element of chance can be introduced into computer applications using module _________.
random.
(Fill-In) The random module’s __________ function enables reproducibility of random sequences.
seed.
(Fill-In) A(n) _______ defines related functions, data and classes. A(n) _________ groups related modules.
module, package.
(Fill-In) Every Python source code (.py) file you create is a(n) ______.
module.
(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.
False. Press Tab, not Enter.
(True/False) Python does not have constants.
True.
(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
True
(True/False) Parameters with default parameter values must be the leftmost arguments in a function’s parameter list.
False. Parameters with default parameter values must appear to the right of parameters that do not have defaults.
(True/False) You must pass keyword arguments in the same order as their corresponding parameters in the function definition’s parameter list.
False. The order of keyword arguments does not matter.
(Fill-In) To define a function with an arbitrary argument list, specify a parameter of the form ________.
*args (again, the name args is used by convention, but is not required).
(Fill-In) An identifier’s ________ describes the region of a program in which the identifier’s value can be accessed.
scope.
(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.
True.
(True/False) You must always import all the identifiers of a given module.
False. You can import only the identifiers you need by using a from…import statement.
(Fill-In) The built-in function ______ returns an object’s unique identifier.
id.
(True/False) Attempts to modify mutable objects create new objects.
False. This is true for immutable objects.
(Fill-In) The stack operations for adding an item to a stack and removing an item from a stack are known as ______ and ______, respectively.
push, pop
(Fill-In) A stack’s items are removed in order.
last-in, first-out (LIFO).
(Discussion) Why do we often work with a sample rather than the full population?
Because often, the full population is unmanageably large.
(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.
False. This an advantage of population standard deviation over population variance.