Chapter 5 Quiz Questions
A(n) _____ is any piece of data that is PASSED INTO A FUNCTION when the function is called.
Argument
A set of statements that BELONG TOGETHER AS A GROUP and contribute to the function definition is known as a(n) _____.
Block
What type of function can be used to determine whether a number is EVEN OR ODD?
Boolean
When a function is called by its name, then it is _____.
Executed
True/False: A LOCAL VARIABLE can be accessed from anywhere in the program.
False
True/False: A function definition SPECIFIES what a function does and causes the function to execute.
False
True/False: In a MENU-DRIVEN program, a loop structure is used to determine the menu item the user selected.
False
True/False: One of the drawbacks of a MODULARIZED program is that the only structure we could use is sequence structure.
False
True/False: The HIERARCHY chart shows all the steps that are taken inside a function.
False
True/False: The math function, ATAN(x), returns one tangent of x in radians.
False
True/False: Unlike other languages, IN PYTHON, the number of values a function can return is limited to one.
False
What type of value is returned by the functions RANDOM AND UNIFORM?
Float
Which of the following functions returns the LARGEST INTEGER that is less than or equal to x?
Floor
What is a GROUP OF STATEMENTS that exists within a program for the purpose of performing a specific task?
Function
A(n) _____ constant is a GLOBAL name that references a value that cannot be changed.
Global
A(n) _____ variable is ACCESSIBLE TO ALL the functions in a program file.
Global
It is recommended that programmers should AVOID USING _____ variables in a program when possible.
Global
The FIRST LINE in the function definition is known as the function _____.
Header
A(n) _____ chart is also known as a structured CHART.
Hierarchy
The _______________ chart is an effective tool that programmers use for DESIGNING AND DOCUMENTING functions.
IPO
Which of the following statements causes the interpreter to load the contents of the RANDOM MODULE into memory?
Import Random
The Python library functions that are BUILT INTO the Python _____ can be used by simply calling the function.
Interpreter
The _____ argument SPECIFIES which parameter the argument should be passed into.
Keyword
A(n) _____ variable is created INSIDE a function.
Local
The Python standard library's _____ module contains numerous functions that can be used in MATHEMATICAL calculations.
Math
What makes it easier to REUSE THE SAME CODE in more than one program?
Modules
A(n) _____ is a variable that RECEIVES AN ARGUMENT that is passed into a function.
Parameter
In a VALUE-RETURNING function, the value of the expression that follows the key word _____ will be sent back to the part of the program that called the function.
Return
A variable's _____ is the part of a program in which the VARIABLE MAY BE ACCESSED.
Scope
The _____ of a local variable is the function in which the VARIABLE IS CREATED.
Scope
Python comes with _____ functions that have been ALREADY PREWRITTEN for the programmer.
Standard
What does the following statement mean? num1, num2 = get_num()
The function get_num() is expected to return a value each for num1 and num2.
The _____ DESIGN technique can be used to break DOWN an algorithm into functions.
Top Down Design
True/False: A value-returning function is like a SIMPLE FUNCTION EXCEPT that when it finishes it returns a value back to the called part of the program.
True
True/False: BOOLEAN functions are useful for simplifying complex conditions that are tested in decision and REPETITION structures.
True
True/False: DIFFERENT functions can have local variables with the SAME NAMES.
True
True/False: IN PYTHON, one can have a list of variables on the left side of the assignment operator.
True
True/False: IN PYTHON, there is no restriction on the name of a module file.
True
True/False: One of the reasons not to use global variables is that it makes a program hard to DEBUG.
True
True/False: PYTHON function names follow the same rules for naming variables.
True
True/False: Python allows for passing MULTIPLE ARGUMENTS to a function.
True
True/False: The RANDRANGE function returns a randomly selected value from a specific sequence of numbers.
True
True/False: The function header marks the beginning of the function definition.
True
True/False: The math function, CEIL(x), returns the smallest integer that is greater than or equal to x.
True
True/False: The value assigned to a global constant can be changed in the MAINLINE LOGIC.
True
True/False: To assign a value to a global variable in a function, the global variable must first be DECLARED in the function.
True
A VALUE-RETURNING function is _____.
a function that will return a VALUE BACK to the part of the program that called it
The term _______________ is used to describe any mechanism that accepts input, performs some operation that CANNOT BE SEEN, and produces output.
black box
The function header BEGINS WITH the keyword _______________ followed by the name of the function.
def
The code for a function is known as a function _______________.
definition
The APPROACH called _______________ is taking a large task and dividing it into several smaller tasks that are easily performed.
divide and conquer
To refer to a function in a module, in our program we have to use the _______________ NOTATION.
dot
A(n) _______________ chart is a VISUAL REPRESENTATION of the relationships between functions.
hierarchy
In a MENU-DRIVEN program, what statement is used to determine and carry out the user's desired action?
if-elif-else
The MAIN function contains a program's _______________ logic, which is the overall logic of the program.
mainline
A(n) _______________ program displays a list of the operations on the screen and allows the user to SELECT THE OPERATION that the program should perform.
menu-driven
The APPROACH of _______________ makes the program easier to understand, test, and maintain.
modularization
Functions in the standard LIBRARY are stored in files that are known as _______________.
modules
Which of the following will assign a random number in the range of 1 through 50 to the variable number?
number = random.randint(1, 50)
Arguments are passed by _______________ to the corresponding PARAMETER variables in the function.
position
The 'P' in the acronym IPO refers to _______________.
processing
The return values of the TRIGonometric functions in Python are in _______________.
radians
In a flowchart, a function call is depicted by a(n) _______________ that has VERTICAL BARS.
rectangle
A VALUE-RETURNING function has a(n) _______________ statement that returns a value back to the part of the program that called it.
return
A variable is VISIBLE only to statements in the variable's _______________.
scope
The top-down design BREAKS DOWN the overall task of the program into a series of _______________.
subtasks
What is the result of the following statement? x = random.randint(5, 15) * 2
A random integer from 5 to 15, multiplied by 2, assigned to the variable x
In Python, a module's file name should end in _______________
.py
Given the following function definition, what would the statement print magic(5) display? def magic(num): return num + 2 * 10
25