# Introduction To Programming – Chapter 5

question
B. Boolean
What type of function can be used to determine whether a number is even or odd?A. evenB. BooleanC. mathD. odd
question
False
True/False: One of the drawbacks of a modularized program is that the only structure we could use is sequence structure.
question
A. if-elif-else
In a menu-driven program, what statement is used to determine and carry out the user's desired action?A. if-elif-elseB. forC. whileD. if-else
question
A. Standard
Python comes with ________ functions that have been already prewritten for the programmer.A. standardB. built-inC. customD. library
question
A. Float
What type of value is returned by the functions random and uniform?A. floatB. integerC. doubleD. number
question
False
True/False: The hierarchy chart shows all the steps that are taken inside a function.
question
False
True/False: Unlike other languages, in Python, the number of values a function can return is limited to one.
question
B. Hierarchy
A( n ) ________ chart is also known as a structured chart.A. flowB. hierarchyC. dataD. organizational
question
True
True/False: The randrange function returns a randomly selected value from a specific sequence of numbers.
question
B. Modules
What makes it easier to reuse the same code in more than one program?A. ProceduresB. ModulesC. FunctionsD. Mods
question
False
True/False: The math function, atan(x), returns one tangent of x in radians.
question
A. Scope
A variable's ________ is the part of a program in which the variable may be accessed.A. scopeB. globalC. argumentD. local
question
True
True/False: To assign a value to a global variable in a function, the global variable must first be declared in the function.
question
False
True/False: A function definition specifies what a function does and causes the function to execute.
question
True
True/False: Boolean functions are useful for simplifying complex conditions that are tested in decision and repetition structures.
question
B. a function that will return a value back to the part of the program that called it
A value-returning function is ________.A. a single statement that performs a specific taskB. a function that will return a value back to the part of the program that called itC. a function that receives a value when it is calledD. called when you want the function to stop
question
True
True/False: Python function names follow the same rules for naming variables.
question
A. Import Random
question
True
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.
question
B. Block
A set of statements that belong together as a group and contribute to the function definition is known as a( n ) ________.A. headerB. blockC. parameterD. return
question
a. function
What is a group of statements that exists within a program for the purpose of performing a specific task?a. functionb. subtaskc. procedured. subprogram
question
The first line in the function definition is known as the function _____.a. headerb. blockc. returnd. parameter
question
c. top-down
The _____ design technique can be used to break down an algorithm into functions.a. subtaskb. blockc. top-downd. simplification
question
d. local
A(n) _____ variable is created inside a function.a. globalb. constantc. definedd. local
question
d. scope
The _____ of a local variable is the function in which the variable is created.a. globalb. definedc. locald. scope
question
b. argument
A(n) _____ is any piece of data that is passed into a function when the function is called.a. globalb. argumentc. scoped. parameter
question
d. parameter
A(n) _____ is a variable that receives an argument that is passed into a function.a. globalb. argumentc. scoped. parameter
question
a. keyword
The _____ argument specifies which parameter the argument should be passed into.a. keywordb. localc. globald. string
question
c. global
A(n) _____ variable is accessible to all the functions in a program file.a. keywordb. localc. globald. string
question
c. global
A(n) _____ constant is a global name that references a value that cannot be changed.a. keywordb. localc. globald. string
question
a. executed
When a function is called by its name, then it is _____.a. executedb. locatedc. definedd. exported
question
b. global
It is recommended that programmers should avoid using _____ variables in a program when possible.a. localb. globalc. string globald. keyword
question
d. interpreter
The Python library functions that are built into the Python _____ can be used by simply calling the function.a. codeb. compilerc. linkerd. interpreter
question
b. number = random.randint(1, 50)
Which of the following will assign a random number in the range of 1 through 50 to the variable number?a. random(1,50) = numberb. number = random.randint(1, 50)c. randint(1, 50) = numberd. number = random(range(1, 50))
question
a. A random integer from 5 to 15, multiplied by 2, assigned to the variable x
What is the result of the following statement?x = random.randint(5, 15) * 2a. A random integer from 5 to 15, multiplied by 2, assigned to the variable xb. A random integer from 5 to 15 assigned to the variable xc. A random integer from 5 to 15, selected in 2 steps, assigned to the variable xd. A random integer from 5 to 15, raised to the power of 2, assigned to the variable x
question
b. return
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. defb. returnc. sentd. result
question
a. math
The Python standard library's _____ module contains numerous functions that can be used in mathematical calculations.a. mathb. stringc. randomd. number
question
a. floor
Which of the following functions returns the largest integer that is less than or equal to x?a. floorb. ceilc. lesserd. greater
question
a. The function get_num() is expected to return a value each for num1 and num2.
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
question
b. 25
Given the following function definition, what would the statement print magic(5) display?def magic(num):return num + 2 * 10a. 70b. 25c. Statement will cause a syntax error.d. Statement will cause a run-time error
question
True
True/False: The function header marks the beginning of the function definition.
question
False
True/False: A local variable can be accessed from anywhere in the program.
question
True
True/False: Different functions can have local variables with the same names
question
True
True/False: Python allows for passing multiple arguments to a function.
question
True
True/False: To assign a value to a global variable in a function, the global variable must first bedeclared in the function.
question
False
True/False: The value assigned to a global constant can be changed in the mainline logic
question
True
True/False: One of the reasons not to use global variables is that it makes a program hard todebug.
question
True
True/False: In Python, one can have a list of variables on the left side of the assignmentoperator
question
False
True/False: In Python, there is no restriction on the name of a module file.
question
True
True/False: In a menu-driven program, a loop structure is used to determine the menu item theuser selected.
question
True
True/False: The math function, ceil(x), returns the smallest integer that is greater than orequal to x.
1 of 51
question
B. Boolean
What type of function can be used to determine whether a number is even or odd?A. evenB. BooleanC. mathD. odd
question
False
True/False: One of the drawbacks of a modularized program is that the only structure we could use is sequence structure.
question
A. if-elif-else
In a menu-driven program, what statement is used to determine and carry out the user's desired action?A. if-elif-elseB. forC. whileD. if-else
question
A. Standard
Python comes with ________ functions that have been already prewritten for the programmer.A. standardB. built-inC. customD. library
question
A. Float
What type of value is returned by the functions random and uniform?A. floatB. integerC. doubleD. number
question
False
True/False: The hierarchy chart shows all the steps that are taken inside a function.
question
False
True/False: Unlike other languages, in Python, the number of values a function can return is limited to one.
question
B. Hierarchy
A( n ) ________ chart is also known as a structured chart.A. flowB. hierarchyC. dataD. organizational
question
True
True/False: The randrange function returns a randomly selected value from a specific sequence of numbers.
question
B. Modules
What makes it easier to reuse the same code in more than one program?A. ProceduresB. ModulesC. FunctionsD. Mods
question
False
True/False: The math function, atan(x), returns one tangent of x in radians.
question
A. Scope
A variable's ________ is the part of a program in which the variable may be accessed.A. scopeB. globalC. argumentD. local
question
True
True/False: To assign a value to a global variable in a function, the global variable must first be declared in the function.
question
False
True/False: A function definition specifies what a function does and causes the function to execute.
question
True
True/False: Boolean functions are useful for simplifying complex conditions that are tested in decision and repetition structures.
question
B. a function that will return a value back to the part of the program that called it
A value-returning function is ________.A. a single statement that performs a specific taskB. a function that will return a value back to the part of the program that called itC. a function that receives a value when it is calledD. called when you want the function to stop
question
True
True/False: Python function names follow the same rules for naming variables.
question
A. Import Random
question
True
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.
question
B. Block
A set of statements that belong together as a group and contribute to the function definition is known as a( n ) ________.A. headerB. blockC. parameterD. return
question
a. function
What is a group of statements that exists within a program for the purpose of performing a specific task?a. functionb. subtaskc. procedured. subprogram
question
The first line in the function definition is known as the function _____.a. headerb. blockc. returnd. parameter
question
c. top-down
The _____ design technique can be used to break down an algorithm into functions.a. subtaskb. blockc. top-downd. simplification
question
d. local
A(n) _____ variable is created inside a function.a. globalb. constantc. definedd. local
question
d. scope
The _____ of a local variable is the function in which the variable is created.a. globalb. definedc. locald. scope
question
b. argument
A(n) _____ is any piece of data that is passed into a function when the function is called.a. globalb. argumentc. scoped. parameter
question
d. parameter
A(n) _____ is a variable that receives an argument that is passed into a function.a. globalb. argumentc. scoped. parameter
question
a. keyword
The _____ argument specifies which parameter the argument should be passed into.a. keywordb. localc. globald. string
question
c. global
A(n) _____ variable is accessible to all the functions in a program file.a. keywordb. localc. globald. string
question
c. global
A(n) _____ constant is a global name that references a value that cannot be changed.a. keywordb. localc. globald. string
question
a. executed
When a function is called by its name, then it is _____.a. executedb. locatedc. definedd. exported
question
b. global
It is recommended that programmers should avoid using _____ variables in a program when possible.a. localb. globalc. string globald. keyword
question
d. interpreter
The Python library functions that are built into the Python _____ can be used by simply calling the function.a. codeb. compilerc. linkerd. interpreter
question
b. number = random.randint(1, 50)
Which of the following will assign a random number in the range of 1 through 50 to the variable number?a. random(1,50) = numberb. number = random.randint(1, 50)c. randint(1, 50) = numberd. number = random(range(1, 50))
question
a. A random integer from 5 to 15, multiplied by 2, assigned to the variable x
What is the result of the following statement?x = random.randint(5, 15) * 2a. A random integer from 5 to 15, multiplied by 2, assigned to the variable xb. A random integer from 5 to 15 assigned to the variable xc. A random integer from 5 to 15, selected in 2 steps, assigned to the variable xd. A random integer from 5 to 15, raised to the power of 2, assigned to the variable x
question
b. return
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. defb. returnc. sentd. result
question
a. math
The Python standard library's _____ module contains numerous functions that can be used in mathematical calculations.a. mathb. stringc. randomd. number
question
a. floor
Which of the following functions returns the largest integer that is less than or equal to x?a. floorb. ceilc. lesserd. greater
question
a. The function get_num() is expected to return a value each for num1 and num2.
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
question
b. 25
Given the following function definition, what would the statement print magic(5) display?def magic(num):return num + 2 * 10a. 70b. 25c. Statement will cause a syntax error.d. Statement will cause a run-time error
question
True
True/False: The function header marks the beginning of the function definition.
question
False
True/False: A local variable can be accessed from anywhere in the program.
question
True
True/False: Different functions can have local variables with the same names
question
True
True/False: Python allows for passing multiple arguments to a function.
question
True
True/False: To assign a value to a global variable in a function, the global variable must first bedeclared in the function.
question
False
True/False: The value assigned to a global constant can be changed in the mainline logic
question
True
True/False: One of the reasons not to use global variables is that it makes a program hard todebug.
question
True