CHAPTER 6
The _______________ chart is an effective tool that programmers use for designing and documenting functions.
IPO
The term _______________ is used to describe any mechanism that accepts input, performs some operation that cannot be seen, and produces output.
Black Box
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
To refer to a function in a module, in our program we have to use the _______________ notation.
Dot
In Python, there is no restriction on the name of a module file.
FALSE
In a menu-driven program, a loop structure is used to determine the menu item the user selected.
FALSE
One of the drawbacks of a modularized program is that the only structure we could use is sequence structure.
FALSE
The math function, atan(x), returns one tangent of x in radians.
FALSE
Unlike other languages, in Python, the number of values a function can return is limited to one.
FALSE
What makes it easier to reuse the same code in more than one program? a. Mods b. Procedures c. Modules d. Functions
c. Modules
A value-returning function is _____. a. a single statement that perform a specific task b. called when you want the function to stop c. a function that will return a value back to the part of the program that called it d. a function that receives a value when it is called
c. a function that will return a value back to the part of the program that called it
What type of value is returned by the functions random and uniform? a. integer b. number c. float d. double
c. float
Given the following function definition, what would the statement print magic(5) display? def magic(num): return num + 2 * 10 a. 70 b. 25 c. Statement will cause a syntax error. d. Statement will cause a run-time error.
b. 25
In a menu-driven program, what statement is used to determine and carry out the user's desired action? a. if-else b. if-elif-else c. while d. for
b. if-elif-else
Which of the following statements causes the interpreter to load the contents of the random module into memory? a. load random b. import random c. upload random d. download random
b. import random
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. a. def b. return c. sent d. result
b. return
In Python, a module's file name should end in _______________.
.py
Which of the following will assign a random number in the range of 1 through 50 to the variable number? a. random(1,50) = number b. number = random.randint(1, 50) c. randint(1, 50) = number d. number = random(range(1, 50))
b. number = random.randint(1, 50)
Python comes with _____ functions that have been already prewritten for the programmer. a. standard b. library c. custom d. built-in
a. standard
The 'P' in the acronym IPO refers to _______________.
Processing
The return values of the trigonometric functions in Python are in _______________.
Radians
A value-returning function has a(n) _______________ statement that returns a value back to the part of the program that called it.
Return
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
Boolean functions are useful for simplifying complex conditions that are tested in decision and repetition structures.
TRUE
In Python, one can have a list of variables on the left side of the assignment operator.
TRUE
The math function, ceil(x), returns the smallest integer that is greater than or equal to x.
TRUE
The randrange function returns a randomly selected value from a specific sequence of numbers.
TRUE
What is the result of the following statement? x = random.randint(5, 15) * 2 a. A random integer from 5 to 15, multiplied by 2, assigned to the variable x b. A random integer from 5 to 15 assigned to the variable x c. A random integer from 5 to 15, selected in 2 steps, assigned to the variable x d. A random integer from 5 to 15, raised to the power of 2, assigned to the variable x
a. A random integer from 5 to 15, multiplied by 2, assigned to the variable x
What does the following statement mean? num1, num2 = get_num() a. The function get_num() is expected to return a value each for num1 and num2. b. The function get_num() is expected to return a value and assign it to num1 and num2. c. Statement will cause a syntax error. d. Statement will cause a run-time error.
a. The function get_num() is expected to return a value each for num1 and num2.
Which of the following functions returns the largest integer that is less than or equal to x? a. floor b. ceil c. lesser d. greater
a. floor
The Python standard library's _____ module contains numerous functions that can be used in mathematical calculations. a. math b. string c. random d. number
a. math
What type of function can be used to determine whether a number is even or odd? a. even b. odd c. math d. Boolean
d. Boolean
The Python library functions that are built into the Python _____ can be used by simply calling the function. a. code b. compiler c. linker d. interpreter
d. interpreter
