Introduction To Programming Using Python 1st Edition Schneider Test Bank Download
Introduction To Programming Using Python 1st Edition Schneider Test Bank Download
Introduction To Programming Using Python 1st Edition Schneider Test Bank Download
Chapter 4
Multiple Choice (24) WARNING: CORRECT ANSWERS ARE IN THE SAME POSITION AND TAGGED WITH **.
YOU SHOULD RANDOMIZE THE LOCATION OF THE CORRECT ANSWERS IN YOUR EXAM.
8. If two variables with the same name are created in two different functions _________.
a. they have no relationship to each other. **
b. they create a conflict with each other.
c. they must be declared to be global.
d. they cause a Traceback error.
9. A variable that can be recognized everywhere in the program is called a _________ variable.
a. global **
b. local
c. all encompassing
d. priority
10. The _________ of a variable is the portion of the program that can refer to it.
a. scope **
12. To gain access to the functions and variables of a library module, use a(n) _________ statement.
a. import **
b. export
c. global
d. library
13. The parameters in a function definition are also called _________ parameters.
a. formal **
b. global
c. actual
d. local
15. Python has an object called _________ that is used to denote a lack of value.
a. None **
b. Null
c. Nothing
d. Empty
16. Which standard library module contains trigonometric, exponential, and logarithmic functions?
a. math **
b. trig
c. engineering
d. geometry
17. When a function returns 2 or more values it is actually returning a(n) _________.
a. tuple **
a. list comprehension **
b. list compression
c. for loop compression
d. list initialization
19. In a function definition, the parameters without default values must _________ the parameters
with default values.
a. precede **
b. follow
c. outnumber
d. not outnumber
20. In a function definition, arguments passed by position must _________ arguments passed by
keyword.
a. precede **
b. follow
c. outnumber
d. not outnumber
21. _________ are one-line mini-functions that can often be used where a simple function is
required.
a. Lambda expressions **
b. De Morgan expressions
c. Boolean expressions
d. all of the above
23. Repeatedly using a “divide-and-conquer” approach to break up a large problem into smaller
subproblems is called _________.
a. stepwise-refinement **
True/False (20)
Answer: false
Answer: false
3. Function definitions must be processed by the Python interpreter before they can be called.
Answer: true
4. When a global statement appears inside a function block, it only affects statements following it
inside its function block.
Answer: true
Answer: false
Answer: true
Answer: false
Answer: true
Answer: false
Answer: true
11. When using list comprehension, you must always use the assigned variable ‘x’.
Answer: false
Answer true
13. List comprehension cannot be applied to arithmetic progressions generated by range functions.
Answer: false
14. In a function definition, the parameters without default values must not precede the
parameters without default values.
Answer: false
15. In a function definition, arguments passed by position must precede arguments passed by
keyword.
Answer: true
16. Positional passing and keyword passing cannot be combined in the same function call.
Answer: false
Answer: true
Answer: false
19. The sort method does not actually alter the order of the items in a list.
Answer: false
Answer: true
1. There are three ways to pass arguments to parameters in a function. List them.
Answer:
1) pass by position
2) pass by keyword
3) pass by default value
square = 2
def main():
square *= square
print(square)
main()
Answer: It produces a Traceback error because the statement “global square” is missing inside the
function.
square = 5
def main():
global square
square *= square
print(square)
main()
Answer: 25
def greeting(n):
for i in range(n):
print(“Hello World!”)
greeting(5)
Answer:
Hello World!
Hello World!
Hello World!
feFiFo()
feFiFo(“see”)
feFiFo(“hear”, “voice”)
feFiFo(“taste”, “juice”, “lemon”)
Answer:
Fe, fi, fo, fum, I smell the blood of an Englishman.
Fe, fi, fo, fum, I see the blood of an Englishman.
Fe, fi, fo, fum, I hear the voice of an Englishman.
Fe, fi, fo, fum, I taste the juice of a lemon.
7. List the four criteria that should be met when using top-down design.
Answer:
1) The design should be easily readable and emphasize small function size.
2) Tasks proceed from general to specific as you read down the chart.
3) They should perform only a single well-defined task.
4) Subtasks should be independent of each other as much as possible and any relationships among
subtasks should be specified.