Chapter 5: Functions

24 July 2022
4.7 (114 reviews)
40 test answers

Unlock all answers in this set

Unlock answers (36)
question
Python functions names follow the same rules as those for naming variables
answer
True
question
The function header marks the beginning of the function definition.
answer
True
question
A function definition specifies what a function does and causes the function to execute.
answer
False
question
A hierarchy chart shows all the steps that are taken inside a function.
answer
False
question
A local variable can be accessed from anywhere in the program.
answer
False
question
Different functions can have local variables with the same names.
answer
True
question
Python allows you to pass multiple arguments to a function.
answer
True
question
To assign a value to a global variable in a function, the global variable must be first declared in the function.
answer
True
question
The value assigned to a global constant can be changed in the mainline logic.
answer
False
question
One reason not to use global variables is that it makes a program hard to debug.
answer
True
question
A value-returning function is like a simple function except that when it finishes it returns a value back to the part of the program that called it.
answer
True
question
Unlike other languages, in Python the number of values a function can return is limited to one.
answer
False
question
In Python you can have a list of variables on the left side of the argument operator.
answer
True
question
In Python there is no restriction on the name of a module file.
answer
False
question
One of the drawbacks of a modularized program is that the only structure you can use in such a program is the sequence structure.
answer
False
question
One reason to store graphics functions in a module is so that you can import the module into any program that needs to use those functions.
answer
True
question
The randrange function returns a randomly selected value from a specific sequence of numbers.
answer
True
question
The math function atan(x) returns one tangent of x in radians.
answer
False
question
The math function ceil(x) returns the smallest integer that is greater than or equal to x.
answer
True
question
Unfortunately, there is no way to store and call on functions when using turtle graphics.
answer
False
question
A function
answer
What is a group of statements that exists within a program for the purpose of performing a specific task?
question
Header
answer
The first line in a function definition is known as the function
question
Top-Down
answer
The ________ design technique can be used to break down an algorithm into functions.
question
Block
answer
A set of statements that belong together as a group and contribute to the function definition is known as a
question
Hierarchy
answer
A(n) ________ chart is also known as a structured chart.
question
Local
answer
A ________ variable is created inside a function.
question
Scope
answer
The ________ of a local variable is the function in which that variable is created.
question
Argument
answer
A(n) ________ is any piece of data that is passed into a function when the function is called.
question
Parameter
answer
A(n) ________ is a variable that receives an argument that is passed into a function.
question
Global
answer
A ________ variable is accessible to all the functions in a program file.
question
Global
answer
A ________ constant is a name that references a value that cannot be changed while the program runs.
question
Executed
answer
When a function is called by its name during the execution of a program, then it is
question
Global
answer
It is recommended that programmers avoid using ________ variables in a program whenever possible.
question
Interpreter
answer
The Python library functions that are built into the Python ________ can be used by simply calling the required function.
question
Standard
answer
Python comes with ________ functions that have already been prewritten for the programmer.
question
Boolean
answer
What type of function can be used to determine whether a number is even or odd?
question
A value-returning function is
answer
a function that will return a value back to the part of the program that called it
question
Import random
answer
Which of the following statements causes the interpreter to load the contents of the random module into memory?
question
Which of the following will assign a random integer in the range of 1 through 50 to the variable number?
answer
number = random.randint(1, 50)
question
What does the following statement mean? num1, num2 = get_num()
answer
The function get_num() is expected to return a value for num1 and for num2.