Python Chapter 5

25 July 2022
4.7 (114 reviews)
30 test answers

Unlock all answers in this set

Unlock answers (26)
question
What is a group of statements that exists within a program for the purpose of performing a specific task?
answer
a function
question
The first line in a function definition is known as the function
answer
header
question
The __________ design technique can be used to break down an algorithm into functions.
answer
Top-Down
question
A set of statements that belong together as a group and contribute to the function definition is known as
answer
block
question
A(n) __________ chart is also known as a structured chart.
answer
hierarchy
question
A __________ variable is created inside a function
answer
local
question
The __________ of a local variable is the function in which that variable is created.
answer
scope
question
A(n) __________ is any piece of data that is passed into a function when the function is called.
answer
Argument
question
A(n) __________ is a variable that receives an argument that is passed into a function.
answer
parameter
question
A __________ variable is accessible to all the functions in a program file.
answer
global
question
A __________ constant is a name that references a value that cannot be changed while the program runs.
answer
global
question
When a function is called by its name during the execution of a program, then it is
answer
executed
question
It is recommended that programmers avoid using __________ variables in a program whenever possible.
answer
global
question
The Python library functions that are built into the Python __________ can be used by simply calling the required function.
answer
interpreter
question
Python comes with __________ functions that have already been prewritten for the programmer.
answer
standard
question
What type of function can be used to determine whether a number is even or odd?
answer
Boolean
question
A value-returning function is
answer
a function that will return a value back to the part of the program that called it
question
Which of the following statements causes the interpreter to load the contents of the random module into memory?
answer
import random
question
Whic of the following will assign a random integer in the range of 1 through 50 to the variable number?
answer
number = random.randint(1, 50)
question
What does the following statement mean? num1, num2 = get_num()
answer
The function get_num() is expected to return a value for num1 and for num2.
question
21. 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()
answer
25
question
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.
answer
return
question
The Python standard library's __________ module contains numerous functions that can be used in mathematical calculations.
answer
math
question
Which of the following functions returns the largest integer that is less than or equal to its argument?
answer
floor
question
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)
answer
Gaddis, Tony
question
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)
answer
None
question
What will be the output after the following code is executed? def pass_it(x, y): z = y**x return(z) num1 = 3 num2 = 4 answer = pass_it(num1, num2) print(answer)
answer
64
question
. What will be displayed after the following code is executed? def pass_it(x, y): z = x*y result = get_result(z) return(result) def get_result(number): z = number + 2 return(z) num1 = 3 num2 = 4 answer = pass_it(num1, num2) print(answer)
answer
14
question
What does the following program do? import turtle def main(): turtle.hideturtle() square(100,0,50,'blue') def square(x, y, width, color): turtle.penup() turtle.goto(x, y) turtle.fillcolor(color) turtle.pendown() turtle.begin_fill() for count in range(4): turtle.forward(width) turtle.left(90) turtle.end_fill() main()
answer
It draws a blue square at coordinates (100, 0), 50 pixels wide, in the lower-left corner.
question
What does the following program do? import turtle def main(): turtle.hideturtle() square(100,0,50,'blue') def square(x, y, width, color): turtle.penup() turtle.goto(x, y) turtle.fillcolor(color) turtle.pendown() turtle.begin_fill() for count in range(2): turtle.forward(width) turtle.left(90) turtle.end_fill() main()
answer
It draws a blue triangle.