Deck 5: Functions and Modules

Full screen (f)
exit full mode
Question
The first line in the function definition is known as the function _____.

A) header
B) block
C) return
D) parameter
Use Space or
up arrow
down arrow
to flip the card.
Question
A variable's _____ is the part of a program in which the variable may be accessed.

A) global
B) argument
C) scope
D) local
Question
It is recommended that programmers should avoid using _____ variables in a program when possible.

A) local
B) global
C) string global
D) keyword
Question
Python comes with _____ functions that have been already prewritten for the programmer.

A) standard
B) library
C) custom
D) built-in
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(n) _____ variable is accessible to all the functions in a program file.

A) keyword
B) local
C) global
D) string
Question
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) return
D) parameter
Question
When a function is called by its name, then it is _____.

A) executed
B) located
C) defined
D) exported
Question
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
A(n) _____ variable is created inside a function.

A) global
B) constant
C) defined
D) local
Question
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
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
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) function
B) subtask
C) procedure
D) subprogram
Question
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
The _____ argument specifies which parameter the argument should be passed into.

A) keyword
B) local
C) global
D) string
Question
A(n) _____ chart is also known as a structured chart.

A) flow
B) data
C) hierarchy
D) organizational
Question
A(n) _____ constant is a global name that references a value that cannot be changed.

A) keyword
B) local
C) global
D) string
Question
The _____ of a local variable is the function in which the variable is created.

A) global
B) defined
C) local
D) scope
Question
A(n) _____ is a variable that receives an argument that is passed into a function.

A) global
B) argument
C) scope
D) parameter
Question
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
One of the reasons not to use global variables is that it makes a program hard to debug.
Question
To assign a value to a global variable in a function, the global variable must first be declared in the function.
Question
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
What type of value is returned by the functions random and uniform?

A) integer
B) number
C) float
D) double
Question
Different functions can have local variables with the same names.
Question
What makes it easier to reuse the same code in more than one program?

A) Mods
B) Procedures
C) Modules
D) Functions
Question
Python allows for passing multiple arguments to a function.
Question
Python function names follow the same rules for naming variables.
Question
The value assigned to a global constant can be changed in the mainline logic.
Question
A function definition specifies what a function does and causes the function to execute.
Question
The function header marks the beginning of the function definition.
Question
A local variable can be accessed from anywhere in the program.
Question
In a menu-driven program, what statement is used to determine and carry out the user's desired action?

A) if-else
B) if-elif-else
C) while
D) for
Question
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 value-returning function is _____.

A) a single statement that perform 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 it is called
Question
The hierarchy chart shows all the steps that are taken inside a function.
Question
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
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
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
In Python, there is no restriction on the name of a module file.
Question
The top-down design breaks down the overall task of the program into a series of _______________.
Question
Boolean functions are useful for simplifying complex conditions that are tested in decision and repetition structures.
Question
In a flowchart, a function call is depicted by a(n) _______________ that has vertical bars.
Question
The function header begins with the keyword _______________ followed by the name of the function.
Question
Arguments are passed by _______________ to the corresponding parameter variables in the function.
Question
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
Functions in the standard library are stored in files that are known as _______________.
Question
Unlike other languages, in Python, the number of values a function can return is limited to one.
Question
The randrange function returns a randomly selected value from a specific sequence of numbers.
Question
The main function contains a program's _______________ logic, which is the overall logic of the program.
Question
A(n) _______________ chart is a visual representation of the relationships between functions.
Question
In a menu-driven program, a loop structure is used to determine the menu item the user selected.
Question
A variable is visible only to statements in the variable's _______________.
Question
The math function, atan(x), returns one tangent of x in radians.
Question
The approach called _______________ is taking a large task and dividing it into several smaller tasks that are easily performed.
Question
The math function, ceil(x), returns the smallest integer that is greater than or equal to x.
Question
The code for a function is known as a function _______________.
Question
In Python, one can have a list of variables on the left side of the assignment operator.
Question
One of the drawbacks of a modularized program is that the only structure we could use is sequence structure.
Question
A(n) _______________ program displays a list of the operations on the screen and allows the user to select the operation that the program should perform.
Question
To refer to a function in a module, in our program we have to use the _______________ notation.
Question
In Python, a module's file name should end in _______________.
Question
The approach of _______________ makes the program easier to understand, test, and maintain.
Question
The return values of the trigonometric functions in Python are in _______________.
Question
The _______________ chart is an effective tool that programmers use for designing and documenting functions.
Question
The 'P' in the acronym IPO refers to _______________.
Question
A value-returning function has a(n) _______________ statement that returns a value back to the part of the program that called it.
Question
The term _______________ is used to describe any mechanism that accepts input, performs some operation that cannot be seen, and produces output.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/69
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 5: Functions and Modules
1
The first line in the function definition is known as the function _____.

A) header
B) block
C) return
D) parameter
A
2
A variable's _____ is the part of a program in which the variable may be accessed.

A) global
B) argument
C) scope
D) local
C
3
It is recommended that programmers should avoid using _____ variables in a program when possible.

A) local
B) global
C) string global
D) keyword
B
4
Python comes with _____ functions that have been already prewritten for the programmer.

A) standard
B) library
C) custom
D) built-in
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
5
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 69 flashcards in this deck.
Unlock Deck
k this deck
6
A(n) _____ 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 69 flashcards in this deck.
Unlock Deck
k this deck
7
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) return
D) parameter
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
8
When a function is called by its name, then it is _____.

A) executed
B) located
C) defined
D) exported
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
9
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
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
10
A(n) _____ variable is created inside a function.

A) global
B) constant
C) defined
D) local
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
11
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
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
12
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
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
13
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 69 flashcards in this deck.
Unlock Deck
k this deck
14
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
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
15
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))
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
16
The _____ argument specifies which parameter the argument should be passed into.

A) keyword
B) local
C) global
D) string
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
17
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 69 flashcards in this deck.
Unlock Deck
k this deck
18
A(n) _____ constant is a global name that references a value that cannot be changed.

A) keyword
B) local
C) global
D) string
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
19
The _____ of a local variable is the function in which the variable is created.

A) global
B) defined
C) local
D) scope
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
20
A(n) _____ is a variable that receives an argument that is passed into a function.

A) global
B) argument
C) scope
D) parameter
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
21
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.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
22
One of the reasons not to use global variables is that it makes a program hard to debug.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
23
To assign a value to a global variable in a function, the global variable must first be declared in the function.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
24
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
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
25
What type of value is returned by the functions random and uniform?

A) integer
B) number
C) float
D) double
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
26
Different functions can have local variables with the same names.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
27
What makes it easier to reuse the same code in more than one program?

A) Mods
B) Procedures
C) Modules
D) Functions
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
28
Python allows for passing multiple arguments to a function.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
29
Python function names follow the same rules for naming variables.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
30
The value assigned to a global constant can be changed in the mainline logic.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
31
A function definition specifies what a function does and causes the function to execute.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
32
The function header marks the beginning of the function definition.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
33
A local variable can be accessed from anywhere in the program.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
34
In a menu-driven program, what statement is used to determine and carry out the user's desired action?

A) if-else
B) if-elif-else
C) while
D) for
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
35
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
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
36
A value-returning function is _____.

A) a single statement that perform 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 it is called
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
37
The hierarchy chart shows all the steps that are taken inside a function.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
38
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.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
39
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 69 flashcards in this deck.
Unlock Deck
k this deck
40
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 69 flashcards in this deck.
Unlock Deck
k this deck
41
In Python, there is no restriction on the name of a module file.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
42
The top-down design breaks down the overall task of the program into a series of _______________.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
43
Boolean functions are useful for simplifying complex conditions that are tested in decision and repetition structures.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
44
In a flowchart, a function call is depicted by a(n) _______________ that has vertical bars.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
45
The function header begins with the keyword _______________ followed by the name of the function.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
46
Arguments are passed by _______________ to the corresponding parameter variables in the function.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
47
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.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
48
Functions in the standard library are stored in files that are known as _______________.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
49
Unlike other languages, in Python, the number of values a function can return is limited to one.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
50
The randrange function returns a randomly selected value from a specific sequence of numbers.
Unlock Deck
Unlock for access to all 69 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 69 flashcards in this deck.
Unlock Deck
k this deck
52
A(n) _______________ chart is a visual representation of the relationships between functions.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
53
In a menu-driven program, a loop structure is used to determine the menu item the user selected.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
54
A variable is visible only to statements in the variable's _______________.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
55
The math function, atan(x), returns one tangent of x in radians.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
56
The approach called _______________ is taking a large task and dividing it into several smaller tasks that are easily performed.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
57
The math function, ceil(x), returns the smallest integer that is greater than or equal to x.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
58
The code for a function is known as a function _______________.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
59
In Python, one can have a list of variables on the left side of the assignment operator.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
60
One of the drawbacks of a modularized program is that the only structure we could use is sequence structure.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
61
A(n) _______________ program displays a list of the operations on the screen and allows the user to select the operation that the program should perform.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
62
To refer to a function in a module, in our program we have to use the _______________ notation.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
63
In Python, a module's file name should end in _______________.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
64
The approach of _______________ makes the program easier to understand, test, and maintain.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
65
The return values of the trigonometric functions in Python are in _______________.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
66
The _______________ chart is an effective tool that programmers use for designing and documenting functions.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
67
The 'P' in the acronym IPO refers to _______________.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
68
A value-returning function has a(n) _______________ statement that returns a value back to the part of the program that called it.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
69
The term _______________ is used to describe any mechanism that accepts input, performs some operation that cannot be seen, and produces output.
Unlock Deck
Unlock for access to all 69 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 69 flashcards in this deck.