Gaddis Python 2e Chapter 03
Download file with the answers
Gaddis Python 2e Chapter 03
1 file(s) 90.67 KB
If you are not a member register here to download this file
Chapter Three
MULTIPLE CHOICE
1. What is a group of statements that exists within a program for the purpose of performing a specific task?
a. function
b. subtask
c. procedure
d. subprogram
2. The first line in the function definition is known as the function _____.
a. header
b. block
c. return
d. parameter
3. The _____ design technique can be used to break down an algorithm into functions.
a. subtask
b. block
c. top-down
d. simplification
4. A set of statements that belong together as a group and contribute to the function definition is known as a(n) _____.
a. header
b. block
c. return
d. parameter
5. A(n) _____ chart is also known as a structured chart.
a. flow
b. data
c. hierarchy
d. organizational
6. A(n) _____ variable is created inside a function.
a. global
b. constant
c. defined
d. local
7. The _____ of a local variable is the function in which the variable is created.
a. global
b. defined
c. local
d. scope
8. A(n) _____ is any piece of data that is passed into a function when the function is called.
a. global
b. argument
c. scope
d. parameter
9. A(n) _____ is a variable that receives an argument that is passed into a function.
a. global
b. argument
c. scope
d. parameter
10. The _____ argument specifies which parameter the argument should be passed into.
a. keyword
b. local
c. global
d. string
11. A(n) _____ variable is accessible to all the functions in a program file.
a. keyword
b. local
c. global
d. string
12. A(n) _____ constant is a global name that references a value that cannot be changed.
a. keyword
b. local
c. global
d. string
13. When a function is called by its name, then it is _____.
a. executed
b. located
c. defined
d. exported
14. It is recommended that programmers should avoid using _____ variables in a program when possible.
a. local
b. global
c. string global
d. keyword
15. A variable’s _____ is the part of a program in which the variable may be accessed.
a. global
b. argument
c. scope
d. local
TRUE/FALSE
1. True/False: Python function names follow the same rules for naming variables.
ANS: T
2. True/False: The function header marks the beginning of the function definition.
ANS: T
3. True/False: A function definition specifies what a function does and causes the function to execute.
ANS: F
4. True/False: The hierarchy chart shows all the steps that are taken inside a function.
ANS: F
5. True/False: A local variable can be accessed from anywhere in the program.
ANS: F
6. True/False: Different functions can have local variables with the same names.
ANS: T
7. True/False: Python allows for passing multiple arguments to a function.
ANS: T
8. True/False: To assign a value to a global variable in a function, the global variable must first be declared in the function.
ANS: T
9. True/False: The value assigned to a global constant can be changed in the mainline logic.
ANS: F
10. True/False: One of the reasons not to use global variables is that it makes a program hard to debug.
ANS: T
FILL IN THE BLANK
1. The approach called _______________ is taking a large task and dividing it into several smaller tasks that are easily performed.
ANS: divide and conquer
2. The code for a function is known as a function _______________.
ANS: definition
3. The function header begins with the keyword _______________ followed by the name of the function.
ANS: def
4. The main function contains a program’s _______________ logic, which is the overall logic of the program.
ANS: mainline
6. In a flowchart, a function call is depicted by a(n) _______________ that has vertical bars.
ANS: rectangle
7. The top-down design breaks down the overall task of the program into a series of _______________.
ANS: subtasks
8. A(n) _______________ chart is a visual representation of the relationships between functions.
ANS: hierarchy
9. Arguments are passed by _______________ to the corresponding parameter variables in the function.
ANS: position
10. A variable is visible only to statements in the variable’s _______________.
ANS: scope
Leave a reply