Week 5 Flashcards
What is a group of statements that exists within a program for the purpose of performing a specific task?
a. a function
b. a subtask
c. a process
d. a subprocess
a. a function
The first line in a function definition is known as the function
a. header
b. block
c. return
d. parameter
a. header
The __________ design technique can be used to break down an algorithm into functions.
a. subtask
b. block
c. top-down
d. simplification
c. top-down
A set of statements that belong together as a group and contribute to the function definition is known as a
a. header
b. block
c. return
d. parameter
b. block
A(n) __________ chart is also known as a structured chart.
a. flow
b. data
c. hierarchy
d. organizational
c. hierarchy
A __________ variable is created inside a function.
a. global
b. constant
c. named constant
d. local
d. local
The __________ of a local variable is the function in which that variable is created.
a. global reach
b. definition
c. space
d. scope
d. scope
A(n) __________ is any piece of data that is passed into a function when the function is called.
a. global variable
b. argument
c. local variable
d. parameter
b. argument
A(n) __________ is a variable that receives an argument that is passed into a function.
a. global variable
b. argument
c. named constant
d. parameter
d. parameter
A __________ variable is accessible to all the functions in a program file.
a. keyword
b. local
c. global
d. string
c. global
A __________ constant is a name that references a value that cannot be changed while the program runs.
a. keyword
b. local
c. global
d. string
c. global
When a function is called by its name during the execution of a program, then it is
a. executed
b. located
c. defined
d. exported
executed
It is recommended that programmers avoid using __________ variables in a program whenever possible.
a. local
b. global
c. string
d. keyword
b. global
The Python library functions that are built into the Python __________ can be used by simply calling the required function.
a. code
b. compiler
c. linker
d. interpreter
d. interpreter
Python comes with __________ functions that have already been prewritten for the programmer.
a. standard
b. library
c. custom
d. key
b. library/standard???
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
A value-returning function is
a. a single statement that performs 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 called
c. a function that will return a value back to the part of the program that called it
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
Which of the following will assign a random integer 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)
What does the following statement mean?
num1, num2 = get_num()
a. The function get_num() is expected to return a value for num1 and for num2.
b. The function get_num() is expected to return one value and assign it to num1 and num2.
c. This statement will cause a syntax error.
d. The function get_num() will receive the values stored in num1 and num2.
a. The function get_num() is expected to return a value for num1 and for num2.
What will display after the following code is executed?
def main():
print(“The answer is”, magic(5))
def magic(num):
answer = num + 2 * 10
return answer
main()
a. 70
b. 25
c. 100
d. The statement will cause a syntax error.
b. 25
In a value-returning function, the value of the expression that follows the keyword __________ will be sent back to the part of the program that called the function.
a. def
b. result
c. sent
d. return
d. return
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
Which of the following functions returns the largest integer that is less than or equal to its argument?
a. floor
b. ceil
c. lesser
d. greater
a. floor
What will be the output after the following code is executed?
def pass_it(x, y):
z = x + “, “ + y
return(z)
name2 = “Tony”
name1 = “Gaddis”
fullname = pass_it(name1, name2)
print(fullname)
Gaddis, Tony
What will be the output after the following code is executed?
def pass_it(x, y):
z = x , “, “ , y
num1 = 4
num2 = 8
answer = pass_it(num1, num2)
print(answer)
None