Deck 6: Value-Returning functions and Modules

Full screen (f)
exit full mode
Question
What makes it easier to reuse the same code in more than one program?

A) Mods
B) Procedures
C) Modules
D) functions
Use Space or
up arrow
down arrow
to flip the card.
Question
Python comes with _____ functions that have been already prewritten for the programmer.

A) standard
B) library
C) custom
D) built-in
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
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
Unlike other languages, in Python, the number of values a function can return is limited to one.
Question
In Python, there is no restriction on the name of a module file.
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
In Python, one can have a list of variables on the left side of the assignment operator.
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 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
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
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
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
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
Boolean functions are useful for simplifying complex conditions that are tested in decision and repetition structures.
Question
What type of value is returned by the functions random and uniform?

A) integer
B) number
C) float
D) double
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
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 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 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
One of the drawbacks of a modularized program is that the only structure we could use is sequence structure.
Question
functions in the standard library are stored in files that are known as _______________.
Question
To refer to a function in a module, in our program we have to use the _______________ notation.
Question
The return values of the trigonometric functions in Python are in _______________.
Question
The randrange function returns a randomly selected value from a specific sequence of numbers.
Question
In a menu-driven program, a loop structure is used to determine the menu item the user selected.
Question
The math function, atan(x), returns one tangent of x in radians.
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 approach of _______________ makes the program easier to understand, test, and maintain.
Question
The term _______________ is used to describe any mechanism that accepts input, performs some operation that cannot be seen, and produces output.
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
The _______________ chart is an effective tool that programmers use for designing and documenting functions.
Question
In Python, a module's file name should end in _______________.
Question
The math function, ceil(x), returns the smallest integer that is greater than or equal to x.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/35
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 6: Value-Returning functions and Modules
1
What makes it easier to reuse the same code in more than one program?

A) Mods
B) Procedures
C) Modules
D) functions
C
2
Python comes with _____ functions that have been already prewritten for the programmer.

A) standard
B) library
C) custom
D) built-in
A
3
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
A
4
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 35 flashcards in this deck.
Unlock Deck
k this deck
5
Unlike other languages, in Python, the number of values a function can return is limited to one.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
6
In Python, there is no restriction on the name of a module file.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
7
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 35 flashcards in this deck.
Unlock Deck
k this deck
8
In Python, one can have a list of variables on the left side of the assignment operator.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
9
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 35 flashcards in this deck.
Unlock Deck
k this deck
10
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 35 flashcards in this deck.
Unlock Deck
k this deck
11
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 35 flashcards in this deck.
Unlock Deck
k this deck
12
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 35 flashcards in this deck.
Unlock Deck
k this deck
13
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 35 flashcards in this deck.
Unlock Deck
k this deck
14
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 35 flashcards in this deck.
Unlock Deck
k this deck
15
Boolean functions are useful for simplifying complex conditions that are tested in decision and repetition structures.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
16
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 35 flashcards in this deck.
Unlock Deck
k this deck
17
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 35 flashcards in this deck.
Unlock Deck
k this deck
18
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 35 flashcards in this deck.
Unlock Deck
k this deck
19
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 35 flashcards in this deck.
Unlock Deck
k this deck
20
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 35 flashcards in this deck.
Unlock Deck
k this deck
21
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 35 flashcards in this deck.
Unlock Deck
k this deck
22
functions in the standard library are stored in files that are known as _______________.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
23
To refer to a function in a module, in our program we have to use the _______________ notation.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
24
The return values of the trigonometric functions in Python are in _______________.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
25
The randrange function returns a randomly selected value from a specific sequence of numbers.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
26
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 35 flashcards in this deck.
Unlock Deck
k this deck
27
The math function, atan(x), returns one tangent of x in radians.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
28
The 'P' in the acronym IPO refers to _______________.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
29
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 35 flashcards in this deck.
Unlock Deck
k this deck
30
The approach of _______________ makes the program easier to understand, test, and maintain.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
31
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 35 flashcards in this deck.
Unlock Deck
k this deck
32
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 35 flashcards in this deck.
Unlock Deck
k this deck
33
The _______________ chart is an effective tool that programmers use for designing and documenting functions.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
34
In Python, a module's file name should end in _______________.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
35
The math function, ceil(x), returns the smallest integer that is greater than or equal to x.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 35 flashcards in this deck.