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.