Deck 7: Modular Design

Full screen (f)
exit full mode
Question
Modular design allows programs to be broken down into manageable size parts, in which each module (part) is a function with clearly specified functionality.
Use Space or
up arrow
down arrow
to flip the card.
Question
A module may be just the design of specific functionality, without any implementation.
Question
A module, in terms of program design, may consist of a single function.
Question
Modules are useful for the design, development, testing and maintenance of computer programs.
Question
The specification of a module is referred to as the module's interface.
Question
A client should always be knowledgeable of the implementation of a module using, and not rely soley on the module's specification (interface).
Question
A docstring is a specific feature of Python for providing the specification of program elements (e.g., functions and modules).
Question
The __doc__ extension in Python is used in the creation of docstrings.
Question
Broadly speaking, a module is

A) a design of specific functionality to be incorporated into a program
B) the implementation of specific functionality to be incorporated into a program
C) a design and/or implementation of specific functionality to be incorporated into a program
D) a function
E) a collection of functions
Question
Which of the following do software modules not facilitate?

A) software design
B) software development
C) software execution speed
D) software testing
E) software modification and maintenance
Question
The interface of a module is

A) an initial set of Python instructions of the module called once by any client
B) specification of the module providing information to any client
C) a common set of Python instructions in both the module and any of lts clients
D) a common specification in both the module and any client of its clients
E) a common set of values shared by both a module and its clients
Question
A docstring is,

A) any Python string used to provide the specification of a program element (e.g., module)
B) any Python string delimited by double quotes providing the specification of a program element.
C) any Python string delimited by triple quotes providing the specification of a program element.
D) any Python string delimited by triple quotes given as the first line of a program element.
E) any triple quoted string in Python
Question
The __doc__ extension in Python is used to

A) display the docstring of a program element
B) display all the docstrings in a given program
C) reassign the docstring of a program element
D) toggle the docstring of a program element on and off
E) returns True or False for determing if a given program element has a provided docstring
Question
Match the following:

-imports a module

A) module
B) interface
C) client
D) docstring
E) __doc__
Question
Match the following:

-displays specification

A) module
B) interface
C) client
D) docstring
E) __doc__
Question
Match the following:

-Python string

A) module
B) interface
C) client
D) docstring
E) __doc__
Question
Match the following:

-design or implementation

A) module
B) interface
C) client
D) docstring
E) __doc__
Question
Match the following:

-specification

A) module
B) interface
C) client
D) docstring
E) __doc__
Question
A ___________________ consists of the design and/or implementation of specific functionality.
Question
The term ____________________ refers to the specification provided for use of a given module. In Python, a _________________ is used to provided such specification.
Question
Any program code that makes use of a given module is called a ____________ of the module.
Question
For the following function,
def elapsed_time(start_hr, start_mins, end_hr, end_mins)
-Give an appropriate docstring specification, where function elapsed_time returns the total number of minutes between the provided start and end times.
Question
For the following function,
def elapsed_time(start_hr, start_mins, end_hr, end_mins)
-GIve a print statement that displays the docstring for this function.
Question
In top-down design, the overall design of a program is developed before the more detailed aspects of the design.
Question
In top-down design, evey module is broken down the same number of levels of submodules.
Question
Top-down design is an approach for developing a _______________ design.
Question
The three top-level modules for the calendar year program in Chapter 7 of the textbook are
______________, ______________________, and ______________________.
Question
Develop a modular design of the typical aspects of a house. Include things such rooms, systems (for example, the plumbing, electrical, and heating systems), and other aspects.
Question
A module in Python is a file containing definitions and statements, which must contain a module declaration statement as the first line.
Question
Modules in Python have their own namespace.
Question
A name clash results when the same identifier is used in more than one function of a given program.
Question
A fully qualified identifier is an identifier with the name of the module that it belongs to prepended to it.
Question
The main module of a Python program is the one that is directly executed when a program is run.
Question
When using the import modulename form of import, the identifiers of the imported module become part of the namespace of the importing module.
Question
When a module is imported using the from modulename import identifier form of import, each imported identifier can be references without needing to be fully qualified.
Question
To avoid name clashes, and to make clear which module each imported identifier comes from, it is recommended that the import modulename form of import be used.
Question
Privates identifiers (variables) of a given module cannot be accessed by any importing module.
Question
When importing a module using the from modulename import * form of import, the private identifiers of the imported module are not imported, but can still be accessed by the importing module.
Question
Modules may have Python code outside of all function definitions that is executed when the module is first loaded.
Question
Built-in function dir() is used to create special directories (folders) for Python modules to be placed.
Question
Which of the following is not true of main modules?

A) main modules are directly executed.
B) main modules are given the name __main__.
C) main modules are meant to be imported into other modules.
D) main modules may import, or include, any number of other modules.
E) main modules provide the basis for a complete Python program.
Question
The following line of code will
From math import factorial as simpFact

A) make every function from the math module available in a client program, but the function factorial will be renamed to simpFact.
B) import only the factorial function from the math module into client, which must be fully qualified when called.
C) import only the factorial function from the math module and integrate it into the namespace of the client as simpFact instead of factorial.
D) this is not proper Python code.
Question
Assuming that the following function exists within a module to be imported into a client, how should the client treat this function?
<strong>Assuming that the following function exists within a module to be imported into a client, how should the client treat this function?  </strong> A) the client can use this function at will as long as it imported. B) this function is private, even if a client imports its module, the function cannot be accessed. C) this function is private, the client can access it but should not. D) the client should print this functions docstring before using it <div style=padding-top: 35px>

A) the client can use this function at will as long as it imported.
B) this function is "private," even if a client imports its module, the function cannot be accessed.
C) this function is "private," the client can access it but should not.
D) the client should print this functions docstring before using it
Question
Which of these is not a type of namespace in Python?

A) foreign Namesapce
B) built-In Namespace
C) global Namespace
D) local Namespace
E) these are all valid namespaces
Question
The main module in Python is given the special name ______________.
Question
The modules of the Python Standard Library are referred to as the Standard ____________ modules.
Question
A _______________ is a container that provides a named context for a set of identifiers.
Question
A _________________ is when two otherwise distinct entities with the same name become part of the same namespace.
Question
If an identifier is written such that it _________________________, then it is unique from all other identifiers in a given program.
Question
If an identifier is written such that it is _________________________, then it is unique from all other identifiers in a given program.
Question
To import a module name into the namespace of another module, the ____________________ form of import is used.
Question
To import all of the identifiers of a given module so that they do not need to be fully qualified in the importin module, the _______________________ form of import is used.
Question
In order to indicate that an identifier of a given module is to be considered private, the identifier begins and ends with ______________________.
Question
In Python, there are as many as three namespaces that can be active at a given time, these are the
_______________ namepace, the ______________ namepace, and the ______________ namespace.
Question
The fundamental operations for altering what is on a stack are ________ and _______.
Question
The operation for seeing what is on the top of stack without removing it is _________.
Question
For the following module,
# module driving_conversions
def milesPerHr(km_speed):
'''Returns miles per hour for kilometers per hour given in speed. '''
def milesPerGal(KilometersPerLiter):
'''Returns miles per gallon for provided kilometers per liter. '''

-Provide a main module that makes use of this module to prompt the user for the conversion desired, and displays the converted result, using the import modulename form of import.
Question
For the following module,
# module driving_conversions
def milesPerHr(km_speed):
'''Returns miles per hour for kilometers per hour given in speed. '''
def milesPerGal(KilometersPerLiter):
'''Returns miles per gallon for provided kilometers per liter. '''

-Modify (a) above using the from modulename import identifier, identifier form of import.
Question
For the following module,
# module driving_conversions
def milesPerHr(km_speed):
'''Returns miles per hour for kilometers per hour given in speed. '''
def milesPerGal(KilometersPerLiter):
'''Returns miles per gallon for provided kilometers per liter. '''

-Modify (a) above using the from modulename import * form of import.
Question
For the following module,
# module driving_conversions
def milesPerHr(km_speed):
'''Returns miles per hour for kilometers per hour given in speed. '''
def milesPerGal(KilometersPerLiter):
'''Returns miles per gallon for provided kilometers per liter. '''

-Modify (a) above using the from modulename import identifier as new_identifier form of import.
Question
For the following module,
# module driving_conversions
def milesPerHr(km_speed):
'''Returns miles per hour for kilometers per hour given in speed. '''
def milesPerGal(KilometersPerLiter):
'''Returns miles per gallon for provided kilometers per liter. '''
-Describe the namespaces for the main modules of (a), (b), (c) and (d) above.
Question
For the stack module given in the chapter, containing functions getStack(), isEmpty(s), top(s), push(s, item) and pop(s), give a main module that prompts the user for a list of numbers (one per line), and displays how many items there are of the last number input.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/62
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 7: Modular Design
1
Modular design allows programs to be broken down into manageable size parts, in which each module (part) is a function with clearly specified functionality.
False
2
A module may be just the design of specific functionality, without any implementation.
True
3
A module, in terms of program design, may consist of a single function.
True
4
Modules are useful for the design, development, testing and maintenance of computer programs.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
5
The specification of a module is referred to as the module's interface.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
6
A client should always be knowledgeable of the implementation of a module using, and not rely soley on the module's specification (interface).
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
7
A docstring is a specific feature of Python for providing the specification of program elements (e.g., functions and modules).
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
8
The __doc__ extension in Python is used in the creation of docstrings.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
9
Broadly speaking, a module is

A) a design of specific functionality to be incorporated into a program
B) the implementation of specific functionality to be incorporated into a program
C) a design and/or implementation of specific functionality to be incorporated into a program
D) a function
E) a collection of functions
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
10
Which of the following do software modules not facilitate?

A) software design
B) software development
C) software execution speed
D) software testing
E) software modification and maintenance
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
11
The interface of a module is

A) an initial set of Python instructions of the module called once by any client
B) specification of the module providing information to any client
C) a common set of Python instructions in both the module and any of lts clients
D) a common specification in both the module and any client of its clients
E) a common set of values shared by both a module and its clients
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
12
A docstring is,

A) any Python string used to provide the specification of a program element (e.g., module)
B) any Python string delimited by double quotes providing the specification of a program element.
C) any Python string delimited by triple quotes providing the specification of a program element.
D) any Python string delimited by triple quotes given as the first line of a program element.
E) any triple quoted string in Python
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
13
The __doc__ extension in Python is used to

A) display the docstring of a program element
B) display all the docstrings in a given program
C) reassign the docstring of a program element
D) toggle the docstring of a program element on and off
E) returns True or False for determing if a given program element has a provided docstring
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
14
Match the following:

-imports a module

A) module
B) interface
C) client
D) docstring
E) __doc__
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
15
Match the following:

-displays specification

A) module
B) interface
C) client
D) docstring
E) __doc__
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
16
Match the following:

-Python string

A) module
B) interface
C) client
D) docstring
E) __doc__
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
17
Match the following:

-design or implementation

A) module
B) interface
C) client
D) docstring
E) __doc__
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
18
Match the following:

-specification

A) module
B) interface
C) client
D) docstring
E) __doc__
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
19
A ___________________ consists of the design and/or implementation of specific functionality.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
20
The term ____________________ refers to the specification provided for use of a given module. In Python, a _________________ is used to provided such specification.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
21
Any program code that makes use of a given module is called a ____________ of the module.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
22
For the following function,
def elapsed_time(start_hr, start_mins, end_hr, end_mins)
-Give an appropriate docstring specification, where function elapsed_time returns the total number of minutes between the provided start and end times.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
23
For the following function,
def elapsed_time(start_hr, start_mins, end_hr, end_mins)
-GIve a print statement that displays the docstring for this function.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
24
In top-down design, the overall design of a program is developed before the more detailed aspects of the design.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
25
In top-down design, evey module is broken down the same number of levels of submodules.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
26
Top-down design is an approach for developing a _______________ design.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
27
The three top-level modules for the calendar year program in Chapter 7 of the textbook are
______________, ______________________, and ______________________.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
28
Develop a modular design of the typical aspects of a house. Include things such rooms, systems (for example, the plumbing, electrical, and heating systems), and other aspects.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
29
A module in Python is a file containing definitions and statements, which must contain a module declaration statement as the first line.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
30
Modules in Python have their own namespace.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
31
A name clash results when the same identifier is used in more than one function of a given program.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
32
A fully qualified identifier is an identifier with the name of the module that it belongs to prepended to it.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
33
The main module of a Python program is the one that is directly executed when a program is run.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
34
When using the import modulename form of import, the identifiers of the imported module become part of the namespace of the importing module.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
35
When a module is imported using the from modulename import identifier form of import, each imported identifier can be references without needing to be fully qualified.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
36
To avoid name clashes, and to make clear which module each imported identifier comes from, it is recommended that the import modulename form of import be used.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
37
Privates identifiers (variables) of a given module cannot be accessed by any importing module.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
38
When importing a module using the from modulename import * form of import, the private identifiers of the imported module are not imported, but can still be accessed by the importing module.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
39
Modules may have Python code outside of all function definitions that is executed when the module is first loaded.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
40
Built-in function dir() is used to create special directories (folders) for Python modules to be placed.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
41
Which of the following is not true of main modules?

A) main modules are directly executed.
B) main modules are given the name __main__.
C) main modules are meant to be imported into other modules.
D) main modules may import, or include, any number of other modules.
E) main modules provide the basis for a complete Python program.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
42
The following line of code will
From math import factorial as simpFact

A) make every function from the math module available in a client program, but the function factorial will be renamed to simpFact.
B) import only the factorial function from the math module into client, which must be fully qualified when called.
C) import only the factorial function from the math module and integrate it into the namespace of the client as simpFact instead of factorial.
D) this is not proper Python code.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
43
Assuming that the following function exists within a module to be imported into a client, how should the client treat this function?
<strong>Assuming that the following function exists within a module to be imported into a client, how should the client treat this function?  </strong> A) the client can use this function at will as long as it imported. B) this function is private, even if a client imports its module, the function cannot be accessed. C) this function is private, the client can access it but should not. D) the client should print this functions docstring before using it

A) the client can use this function at will as long as it imported.
B) this function is "private," even if a client imports its module, the function cannot be accessed.
C) this function is "private," the client can access it but should not.
D) the client should print this functions docstring before using it
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
44
Which of these is not a type of namespace in Python?

A) foreign Namesapce
B) built-In Namespace
C) global Namespace
D) local Namespace
E) these are all valid namespaces
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
45
The main module in Python is given the special name ______________.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
46
The modules of the Python Standard Library are referred to as the Standard ____________ modules.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
47
A _______________ is a container that provides a named context for a set of identifiers.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
48
A _________________ is when two otherwise distinct entities with the same name become part of the same namespace.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
49
If an identifier is written such that it _________________________, then it is unique from all other identifiers in a given program.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
50
If an identifier is written such that it is _________________________, then it is unique from all other identifiers in a given program.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
51
To import a module name into the namespace of another module, the ____________________ form of import is used.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
52
To import all of the identifiers of a given module so that they do not need to be fully qualified in the importin module, the _______________________ form of import is used.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
53
In order to indicate that an identifier of a given module is to be considered private, the identifier begins and ends with ______________________.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
54
In Python, there are as many as three namespaces that can be active at a given time, these are the
_______________ namepace, the ______________ namepace, and the ______________ namespace.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
55
The fundamental operations for altering what is on a stack are ________ and _______.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
56
The operation for seeing what is on the top of stack without removing it is _________.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
57
For the following module,
# module driving_conversions
def milesPerHr(km_speed):
'''Returns miles per hour for kilometers per hour given in speed. '''
def milesPerGal(KilometersPerLiter):
'''Returns miles per gallon for provided kilometers per liter. '''

-Provide a main module that makes use of this module to prompt the user for the conversion desired, and displays the converted result, using the import modulename form of import.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
58
For the following module,
# module driving_conversions
def milesPerHr(km_speed):
'''Returns miles per hour for kilometers per hour given in speed. '''
def milesPerGal(KilometersPerLiter):
'''Returns miles per gallon for provided kilometers per liter. '''

-Modify (a) above using the from modulename import identifier, identifier form of import.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
59
For the following module,
# module driving_conversions
def milesPerHr(km_speed):
'''Returns miles per hour for kilometers per hour given in speed. '''
def milesPerGal(KilometersPerLiter):
'''Returns miles per gallon for provided kilometers per liter. '''

-Modify (a) above using the from modulename import * form of import.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
60
For the following module,
# module driving_conversions
def milesPerHr(km_speed):
'''Returns miles per hour for kilometers per hour given in speed. '''
def milesPerGal(KilometersPerLiter):
'''Returns miles per gallon for provided kilometers per liter. '''

-Modify (a) above using the from modulename import identifier as new_identifier form of import.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
61
For the following module,
# module driving_conversions
def milesPerHr(km_speed):
'''Returns miles per hour for kilometers per hour given in speed. '''
def milesPerGal(KilometersPerLiter):
'''Returns miles per gallon for provided kilometers per liter. '''
-Describe the namespaces for the main modules of (a), (b), (c) and (d) above.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
62
For the stack module given in the chapter, containing functions getStack(), isEmpty(s), top(s), push(s, item) and pop(s), give a main module that prompts the user for a list of numbers (one per line), and displays how many items there are of the last number input.
Unlock Deck
Unlock for access to all 62 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 62 flashcards in this deck.