Deck 5: Functions

Full screen (f)
exit full mode
Question
Unlike other languages,in Python the number of values a function can return is limited to one.
Use Space or
up arrow
down arrow
to flip the card.
Question
In Python there is no restriction on the name of a module file.
Question
The math function ceil(x)returns the smallest integer that is greater than or equal to x.
Question
One of the drawbacks of a modularized program is that the only structure you can use in such a program is the sequence structure.
Question
One reason to store graphics functions in a module is so that you can import the module into any program that needs to use those functions.
Question
The math function atan(x)returns one tangent of x in radians.
Question
A hierarchy chart shows all the steps that are taken inside a function.
Question
Different functions can have local variables with the same names.
Question
The function header marks the beginning of the function definition.
Question
In Python you can have a list of variables on the left side of the argument operator.
Question
One reason not to use global variables is that it makes a program hard to debug.
Question
The value assigned to a global constant can be changed in the mainline logic.
Question
Python allows you to pass multiple arguments to a function.
Question
Unfortunately,there is no way to store and call on functions when using turtle graphics.
Question
Python function names follow the same rules as those for naming variables.
Question
A local variable can be accessed from anywhere in the program.
Question
To assign a value to a global variable in a function,the global variable must be first declared in the function.
Question
A function definition specifies what a function does and causes the function to execute.
Question
A value-returning function is like a simple function except that when it finishes it returns a value back to the part of the program that called it.
Question
The randrange function returns a randomly selected value from a specific sequence of numbers.
Question
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
Question
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
Question
A __________ variable is accessible to all the functions in a program file.

A) keyword
B) local
C) global
D) string
Question
Whic 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))
Question
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.
Question
A __________ variable is created inside a function.

A) global
B) constant
C) named constant
D) local
Question
The __________ design technique can be used to break down an algorithm into functions.

A) subtask
B) block
C) top-down
D) simplification
Question
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
Question
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
Question
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
Question
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
Question
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
Question
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
Question
The __________ of a local variable is the function in which that variable is created.

A) global reach
B) definition
C) space
D) scope
Question
A(n)__________ chart is also known as a structured chart.

A) flow
B) data
C) hierarchy
D) organizational
Question
The first line in a function definition is known as the function

A) header
B) block
C) return
D) parameter
Question
Python comes with __________ functions that have already been prewritten for the programmer.

A) standard
B) library
C) custom
D) key
Question
What type of function can be used to determine whether a number is even or odd?

A) even
B) odd
C) math
D) Boolean
Question
It is recommended that programmers avoid using __________ variables in a program whenever possible.

A) local
B) global
C) string
D) keyword
Question
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
Question
Functions that are in the standard library are stored in files that are known as __________.
Question
What will be the output after the following code is executed?
<strong>What will be the output after the following code is executed?  </strong> A) 81 B) 64 C) 12 D) None <div style=padding-top: 35px>

A) 81
B) 64
C) 12
D) None
Question
A variable is available only to statements in the variable's __________.
Question
To refer to a function in a module,Python uses ___________ notation.
Question
What does the following program do?
<strong>What does the following program do?  </strong> A) It draws a blue square at coordinates (100, 0), 50 pixels wide, starting at the top right corner. B) It draws a blue square at coordinates (0, 50), 100 pixels wide, starting at the top right corner. C) It draws a blue square at coordinates (100, 0), 50 pixels wide, in the lower-left corner. D) Nothing since you cannot call a function with turtle graphics. <div style=padding-top: 35px>

A) It draws a blue square at coordinates (100, 0), 50 pixels wide, starting at the top right corner.
B) It draws a blue square at coordinates (0, 50), 100 pixels wide, starting at the top right corner.
C) It draws a blue square at coordinates (100, 0), 50 pixels wide, in the lower-left corner.
D) Nothing since you cannot call a function with turtle graphics.
Question
The top-down design breaks down the overall task of a program into a series of __________.
Question
What will be the output after the following code is executed?
<strong>What will be the output after the following code is executed?  </strong> A) Tony Gaddis B) Gaddis Tony C) Tony, Gaddis D) Gaddis, Tony <div style=padding-top: 35px>

A) Tony Gaddis
B) Gaddis Tony
C) Tony, Gaddis
D) Gaddis, Tony
Question
What does the following program do?
<strong>What does the following program do?  </strong> A) It draws a blue square. B) It draws a blue triangle. C) It draws 2 blue lines. D) Nothing since you cannot call a function with turtle graphics. <div style=padding-top: 35px>

A) It draws a blue square.
B) It draws a blue triangle.
C) It draws 2 blue lines.
D) Nothing since you cannot call a function with turtle graphics.
Question
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.
Question
The code for a function is known as a function ___________.
Question
The main function contains a program's __________ logic which is the overall logic of the program.
Question
Arguments are passed by __________ to the corresponding parameter variables in a function.
Question
What will be the output after the following code is executed?
<strong>What will be the output after the following code is executed?  </strong> A) 4, 8 B) 8, 4 C) 48 D) None <div style=padding-top: 35px>

A) 4, 8
B) 8, 4
C) 48
D) None
Question
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
The function header begins with the keyword __________ and is followed by the name of the function.
Question
What will be displayed after the following code is executed?
<strong>What will be displayed after the following code is executed?  </strong> A) 12 B) 9 C) 14 D) Nothing, this code contains a syntax error. <div style=padding-top: 35px>

A) 12
B) 9
C) 14
D) Nothing, this code contains a syntax error.
Question
In a flowchart,a function call is depicted by a(n)___________.
Question
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
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.

A) def
B) result
C) sent
D) return
Question
A(n)__________ chart is a visual representation of the relationships between functions.
Question
The approach known as __________ makes a program easier to understand,test,and maintain.
Question
The ___________ chart is an effective tool used by programmers to design and document functions.
Question
A value-returning function has a(n)___________ statement that sends a value back to the part of the program that called it.
Question
The return values of the trigonometric functions in Python are in __________.
Question
The 'P' in the acronym IPO refers to ___________.
Question
In Python,a module's file name should end in ___________.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/66
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 5: Functions
1
Unlike other languages,in Python the number of values a function can return is limited to one.
False
2
In Python there is no restriction on the name of a module file.
False
3
The math function ceil(x)returns the smallest integer that is greater than or equal to x.
True
4
One of the drawbacks of a modularized program is that the only structure you can use in such a program is the sequence structure.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
5
One reason to store graphics functions in a module is so that you can import the module into any program that needs to use those functions.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
6
The math function atan(x)returns one tangent of x in radians.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
7
A hierarchy chart shows all the steps that are taken inside a function.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
8
Different functions can have local variables with the same names.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
9
The function header marks the beginning of the function definition.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
10
In Python you can have a list of variables on the left side of the argument operator.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
11
One reason not to use global variables is that it makes a program hard to debug.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
12
The value assigned to a global constant can be changed in the mainline logic.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
13
Python allows you to pass multiple arguments to a function.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
14
Unfortunately,there is no way to store and call on functions when using turtle graphics.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
15
Python function names follow the same rules as those for naming variables.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
16
A local variable can be accessed from anywhere in the program.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
17
To assign a value to a global variable in a function,the global variable must be first declared in the function.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
18
A function definition specifies what a function does and causes the function to execute.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
19
A value-returning function is like a simple function except that when it finishes it returns a value back to the part of the program that called it.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
20
The randrange function returns a randomly selected value from a specific sequence of numbers.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
21
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
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
22
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
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
23
A __________ variable is accessible to all the functions in a program file.

A) keyword
B) local
C) global
D) string
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
24
Whic 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))
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
25
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.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
26
A __________ variable is created inside a function.

A) global
B) constant
C) named constant
D) local
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
27
The __________ design technique can be used to break down an algorithm into functions.

A) subtask
B) block
C) top-down
D) simplification
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
28
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
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
29
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
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
30
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
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
31
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
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
32
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
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
33
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
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
34
The __________ of a local variable is the function in which that variable is created.

A) global reach
B) definition
C) space
D) scope
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
35
A(n)__________ chart is also known as a structured chart.

A) flow
B) data
C) hierarchy
D) organizational
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
36
The first line in a function definition is known as the function

A) header
B) block
C) return
D) parameter
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
37
Python comes with __________ functions that have already been prewritten for the programmer.

A) standard
B) library
C) custom
D) key
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
38
What type of function can be used to determine whether a number is even or odd?

A) even
B) odd
C) math
D) Boolean
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
39
It is recommended that programmers avoid using __________ variables in a program whenever possible.

A) local
B) global
C) string
D) keyword
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
40
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
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
41
Functions that are in the standard library are stored in files that are known as __________.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
42
What will be the output after the following code is executed?
<strong>What will be the output after the following code is executed?  </strong> A) 81 B) 64 C) 12 D) None

A) 81
B) 64
C) 12
D) None
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
43
A variable is available only to statements in the variable's __________.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
44
To refer to a function in a module,Python uses ___________ notation.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
45
What does the following program do?
<strong>What does the following program do?  </strong> A) It draws a blue square at coordinates (100, 0), 50 pixels wide, starting at the top right corner. B) It draws a blue square at coordinates (0, 50), 100 pixels wide, starting at the top right corner. C) It draws a blue square at coordinates (100, 0), 50 pixels wide, in the lower-left corner. D) Nothing since you cannot call a function with turtle graphics.

A) It draws a blue square at coordinates (100, 0), 50 pixels wide, starting at the top right corner.
B) It draws a blue square at coordinates (0, 50), 100 pixels wide, starting at the top right corner.
C) It draws a blue square at coordinates (100, 0), 50 pixels wide, in the lower-left corner.
D) Nothing since you cannot call a function with turtle graphics.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
46
The top-down design breaks down the overall task of a program into a series of __________.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
47
What will be the output after the following code is executed?
<strong>What will be the output after the following code is executed?  </strong> A) Tony Gaddis B) Gaddis Tony C) Tony, Gaddis D) Gaddis, Tony

A) Tony Gaddis
B) Gaddis Tony
C) Tony, Gaddis
D) Gaddis, Tony
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
48
What does the following program do?
<strong>What does the following program do?  </strong> A) It draws a blue square. B) It draws a blue triangle. C) It draws 2 blue lines. D) Nothing since you cannot call a function with turtle graphics.

A) It draws a blue square.
B) It draws a blue triangle.
C) It draws 2 blue lines.
D) Nothing since you cannot call a function with turtle graphics.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
49
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.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
50
The code for a function is known as a function ___________.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
51
The main function contains a program's __________ logic which is the overall logic of the program.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
52
Arguments are passed by __________ to the corresponding parameter variables in a function.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
53
What will be the output after the following code is executed?
<strong>What will be the output after the following code is executed?  </strong> A) 4, 8 B) 8, 4 C) 48 D) None

A) 4, 8
B) 8, 4
C) 48
D) None
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
54
The Python standard library's __________ module contains numerous functions that can be used in mathematical calculations.

A) math
B) string
C) random
D) number
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
55
The function header begins with the keyword __________ and is followed by the name of the function.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
56
What will be displayed after the following code is executed?
<strong>What will be displayed after the following code is executed?  </strong> A) 12 B) 9 C) 14 D) Nothing, this code contains a syntax error.

A) 12
B) 9
C) 14
D) Nothing, this code contains a syntax error.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
57
In a flowchart,a function call is depicted by a(n)___________.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
58
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
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
59
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
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
60
A(n)__________ chart is a visual representation of the relationships between functions.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
61
The approach known as __________ makes a program easier to understand,test,and maintain.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
62
The ___________ chart is an effective tool used by programmers to design and document functions.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
63
A value-returning function has a(n)___________ statement that sends a value back to the part of the program that called it.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
64
The return values of the trigonometric functions in Python are in __________.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
65
The 'P' in the acronym IPO refers to ___________.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
66
In Python,a module's file name should end in ___________.
Unlock Deck
Unlock for access to all 66 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 66 flashcards in this deck.