Introduction To Programming - Chapter 5

24 July 2022
4.7 (114 reviews)
51 test answers

Unlock all answers in this set

Unlock answers (47)
question
B. Boolean
answer
What type of function can be used to determine whether a number is even or odd? A. even B. Boolean C. math D. odd
question
False
answer
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
answer
In a menu-driven program, what statement is used to determine and carry out the user's desired action? A. if-elif-else B. for C. while D. if-else
question
A. Standard
answer
Python comes with ________ functions that have been already prewritten for the programmer. A. standard B. built-in C. custom D. library
question
A. Float
answer
What type of value is returned by the functions random and uniform? A. float B. integer C. double D. number
question
False
answer
True/False: The hierarchy chart shows all the steps that are taken inside a function.
question
False
answer
True/False: Unlike other languages, in Python, the number of values a function can return is limited to one.
question
B. Hierarchy
answer
A( n ) ________ chart is also known as a structured chart. A. flow B. hierarchy C. data D. organizational
question
True
answer
True/False: The randrange function returns a randomly selected value from a specific sequence of numbers.
question
B. Modules
answer
What makes it easier to reuse the same code in more than one program? A. Procedures B. Modules C. Functions D. Mods
question
False
answer
True/False: The math function, atan(x), returns one tangent of x in radians.
question
A. Scope
answer
A variable's ________ is the part of a program in which the variable may be accessed. A. scope B. global C. argument D. local
question
True
answer
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
answer
True/False: A function definition specifies what a function does and causes the function to execute.
question
True
answer
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
answer
A value-returning function is ________. A. a single statement that performs a specific task B. a function that will return a value back to the part of the program that called it C. a function that receives a value when it is called D. called when you want the function to stop
question
True
answer
True/False: Python function names follow the same rules for naming variables.
question
A. Import Random
answer
Which of the following statements causes the interpreter to load the contents of the random module into memory? A. import random B. load random C. download random D. upload random
question
True
answer
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
answer
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. parameter D. return
question
a. function
answer
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
question
a. header
answer
The first line in the function definition is known as the function _____. a. header b. block c. return d. parameter
question
c. top-down
answer
The _____ design technique can be used to break down an algorithm into functions. a. subtask b. block c. top-down d. simplification
question
d. local
answer
A(n) _____ variable is created inside a function. a. global b. constant c. defined d. local
question
d. scope
answer
The _____ of a local variable is the function in which the variable is created. a. global b. defined c. local d. scope
question
b. argument
answer
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
question
d. parameter
answer
A(n) _____ is a variable that receives an argument that is passed into a function. a. global b. argument c. scope d. parameter
question
a. keyword
answer
The _____ argument specifies which parameter the argument should be passed into. a. keyword b. local c. global d. string
question
c. global
answer
A(n) _____ variable is accessible to all the functions in a program file. a. keyword b. local c. global d. string
question
c. global
answer
A(n) _____ constant is a global name that references a value that cannot be changed. a. keyword b. local c. global d. string
question
a. executed
answer
When a function is called by its name, then it is _____. a. executed b. located c. defined d. exported
question
b. global
answer
It is recommended that programmers should avoid using _____ variables in a program when possible. a. local b. global c. string global d. keyword
question
d. interpreter
answer
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
question
b. number = random.randint(1, 50)
answer
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))
question
a. A random integer from 5 to 15, multiplied by 2, assigned to the variable x
answer
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
question
b. return
answer
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
question
a. math
answer
The Python standard library's _____ module contains numerous functions that can be used in mathematical calculations. a. math b. string c. random d. number
question
a. floor
answer
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
question
a. The function get_num() is expected to return a value each for num1 and num2.
answer
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
answer
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
question
True
answer
True/False: The function header marks the beginning of the function definition.
question
False
answer
True/False: A local variable can be accessed from anywhere in the program.
question
True
answer
True/False: Different functions can have local variables with the same names
question
True
answer
True/False: Python allows for passing multiple arguments to a function.
question
True
answer
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
answer
True/False: The value assigned to a global constant can be changed in the mainline logic
question
True
answer
True/False: One of the reasons not to use global variables is that it makes a program hard to debug.
question
True
answer
True/False: In Python, one can have a list of variables on the left side of the assignment operator
question
False
answer
True/False: In Python, there is no restriction on the name of a module file.
question
True
answer
True/False: In a menu-driven program, a loop structure is used to determine the menu item the user selected.
question
True
answer
True/False: The math function, ceil(x), returns the smallest integer that is greater than or equal to x.