Deck 8: Modules and Functions

ملء الشاشة (f)
exit full mode
سؤال
Structured programming, the method for creating all programs from sequence, selection, and repetition structures, is about clarity.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Clumsy programming involves code that repeats throughout a program, long modules without any apparent organization, and use of the infamous GOTO statement.
سؤال
Modules cannot call other modules.
سؤال
In most programming languages, global variables are declared explicitly as global or declared in the main module outside any other modules.
سؤال
In general, variables are assumed to be global unless they are declared as local.
سؤال
All variables declared in separate modules are global and cannot be affected by other modules.
سؤال
If two variables in different modules happen to have the same name, they are stored in different memory locations, and the statements affecting one do not affect the other.
سؤال
The flowchart shape for a called module is a parallelogram with stripes, which indicates a predefined process.
سؤال
A For loop is depicted like a While loop in a flowchart, with initialization and incrementing as separate steps.
سؤال
An efficient way of providing data to modules and still allowing the use of local variables is to pass the data as an argument.
سؤال
Data sent when a module is called is a parameter.
سؤال
A parameter consists of the data type and variable pair to receive the data.
سؤال
Modules can be designed to accept more than one argument.
سؤال
Parameters and arguments must match in number, data type, and order.
سؤال
Functions can return more than one value.
سؤال
When you call a module by using an argument, you are sending data to the module.
سؤال
Functions return values by sending data back to the calling module.
سؤال
You should design your modules and functions to be capable of being used in more than one way.
سؤال
Low coupling limits a module's flexibility.
سؤال
Modularizing a program makes it more efficient by including highly cohesive code and calling another module for each separate task.
سؤال
If you have more than five to six statements that are closely related to the same purpose and have the potential of being used in more than one place in your program, you should consider turning these statements into a module.
سؤال
Modules cannot be reused in a program.
سؤال
Programmers can work on separate modules for efficiency without having to worry about variable names used in other modules.
سؤال
An advantage of modularization is that the main module is easier to understand yet still gives the "big picture" of what's happening.
سؤال
In a pseudocode class definition, if a method returns a value, the method header starts with the method name
سؤال
A(n) ____ is simply a section of a program that performs a specific task.

A) module
B) constant
C) argument
D) parameter
سؤال
Instead of listing all the code in the main program, your main program calls the ____.

A) argument
B) parameter
C) module
D) constant
سؤال
____ is used to create a program's overall outline and describe tasks to be accomplished, and then details of these tasks are refined later.

A) Cohesion
B) Top-down design
C) Coupling
D) Bottom-up design
سؤال
When output is meant for the screen, you should use the ____ keyword.

A) Declare
B) Print
C) Display
D) Input
سؤال
When output is meant for a printer, you should use the ____ keyword.

A) Print
B) Input
C) Display
D) Declare
سؤال
____ are created when a module is called and exist only while statements in the module are performed.

A) Arguments
B) Global variables
C) Parameters
D) Local variables
سؤال
With modular programming, a variable's ____ is the section of program code in which a variable can be accessed.

A) overhead
B) scope
C) coupling
D) cohesion
سؤال
____ are available to all modules in the program.

A) Arguments
B) Global variables
C) Local variables
D) Parameters
سؤال
In the code below, why is it that the displayName() module cannot print the person's name?
Start
Call getInput()
Call displayName()
Stop
Module getInput()
Declare String name
Display "Enter your name: "
Input name
End Module
Module displayName()
Display "Your name is: " + name
End Module

A) The name variable is outside the displayName() module's scope.
B) The name variable is a global variable.
C) The name variable is strongly cohesive.
D) The name variable has high coupling.
سؤال
In which of the following is the variable name declared as a global variable?

A) Start
Call getInput()
Call displayName()
Stop
Module getInput()
Declare String name
Display "Enter your name"
Input name
End Module
Module displayName()
Display "Your name is: " + name
End Module

B) Start
Call getInput()
Call displayName()
Stop
Module getInput()
Display "Enter your name"
Input name
End Module
Module displayName()
Declare String name
Display "Your name is: " + name
End Module

C) Start
Call name
Call getInput()
Call displayName()
Stop
Module getInput()
Display "Enter your name"
Input name
End Module
Module displayName()
Declare String name
Display "Your name is: " + name
End Module

D) Start
Declare String name
Call getInput()
Call displayName()
Stop
Module getInput()
Display "Enter your name"
Input name
End Module
Module displayName()
Display "Your name is: " + name
End Module
سؤال
Why is it that all variables are not declared as global?

A) Local variables, in different modules, are completely dependent on each other.
B) Local variables are restrictive.
C) By using local variables, programmers working on a module do not have to worry about what variable names are used in the main module or any other module.
D) Global variables, in different modules, are completely dependent on each other.
سؤال
What happens if a module uses a local variable with the same name as a main module variable, which is assumed to be global?

A) In this case, the variable declared globally is used.
B) It would cause a syntax error.
C) It would cause a logic error.
D) In this case, the variable declared locally is used.
سؤال
____ are values represented as constants or variables, which are enclosed in the parentheses following the module name in the Call statement.

A) Data types
B) Parameters
C) Data sets
D) Arguments
سؤال
Which of the following statements is true?

A) Data types do not need to be declared in function parameters.
B) Modules are designed to accept only one argument.
C) Typically, parameter variable names are longer than variable names in the main module to indicate their permanent nature.
D) Data types must be declared in function parameters.
سؤال
Sending the value of a variable or constant to a module, where a local variable is initialized to the argument's value is known as ____.

A) passing by value
B) coupling
C) passing by reference
D) cohesion
سؤال
When ____, the variable's actual memory address is sent to the module, and the parameter variable is the same location in memory as the variable in the calling module.

A) passing by value
B) cohesion
C) passing by reference
D) coupling
سؤال
A ____ error occurs when JavaScript's language rules are violated.

A) global
B) syntax
C) local
D) logic
سؤال
A ____ error occurs when the wrong instruction is given to the computer for solving a problem.

A) local
B) syntax
C) global
D) logic
سؤال
With a ____ error, the syntax is correct so the computer can process the instruction, but it is not the correct instruction.

A) global
B) syntax
C) local
D) logic
سؤال
A ____ is a value that is sent back to the calling module from a called module.

A) return value
B) parameter
C) constructor
D) argument
سؤال
____ is the measure of the degree to which all statements and variables in the module relate to one purpose.

A) Coupling
B) Vulnerability
C) Cohesion
D) Efficiency
سؤال
____ is the degree to which a module depends on other modules to do its work.

A) Cohesion
B) Coupling
C) Efficiency
D) Vulnerability
سؤال
The following function has ____.
Function Numeric average()
// Declare variables
Declare Numeric inputNum // number entered
Declare Numeric quantity // numbers input
Declare Numeric total = 0 // accumulated total
Declare Numeric index // loop variable
Declare Numeric avg // avg of numbers

// Ask user how many numbers to input
Display "How many numbers will you input? "
Input quantity

// Ask user how many numbers to input
Display "How many numbers will you input? "
Input quantity

// Compute and return average, end function
Avg = total / quantity
Return avg
End Function

A) strong cohesion
B) high coupling
C) weak cohesion
D) strong vulnerability
سؤال
You might be "____" your code if you write a separate module for every task.

A) over designing
B) overmodularizing
C) over programming
D) strongly coupling
سؤال
The prompt() command in JavaScript is actually a(n) ____.

A) variable
B) parameter
C) function
D) argument
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/50
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 8: Modules and Functions
1
Structured programming, the method for creating all programs from sequence, selection, and repetition structures, is about clarity.
True
2
Clumsy programming involves code that repeats throughout a program, long modules without any apparent organization, and use of the infamous GOTO statement.
True
3
Modules cannot call other modules.
False
4
In most programming languages, global variables are declared explicitly as global or declared in the main module outside any other modules.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
5
In general, variables are assumed to be global unless they are declared as local.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
6
All variables declared in separate modules are global and cannot be affected by other modules.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
7
If two variables in different modules happen to have the same name, they are stored in different memory locations, and the statements affecting one do not affect the other.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
8
The flowchart shape for a called module is a parallelogram with stripes, which indicates a predefined process.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
9
A For loop is depicted like a While loop in a flowchart, with initialization and incrementing as separate steps.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
10
An efficient way of providing data to modules and still allowing the use of local variables is to pass the data as an argument.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
11
Data sent when a module is called is a parameter.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
12
A parameter consists of the data type and variable pair to receive the data.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
13
Modules can be designed to accept more than one argument.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
14
Parameters and arguments must match in number, data type, and order.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
15
Functions can return more than one value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
16
When you call a module by using an argument, you are sending data to the module.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
17
Functions return values by sending data back to the calling module.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
18
You should design your modules and functions to be capable of being used in more than one way.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
19
Low coupling limits a module's flexibility.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
20
Modularizing a program makes it more efficient by including highly cohesive code and calling another module for each separate task.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
21
If you have more than five to six statements that are closely related to the same purpose and have the potential of being used in more than one place in your program, you should consider turning these statements into a module.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
22
Modules cannot be reused in a program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
23
Programmers can work on separate modules for efficiency without having to worry about variable names used in other modules.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
24
An advantage of modularization is that the main module is easier to understand yet still gives the "big picture" of what's happening.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
25
In a pseudocode class definition, if a method returns a value, the method header starts with the method name
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
26
A(n) ____ is simply a section of a program that performs a specific task.

A) module
B) constant
C) argument
D) parameter
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
27
Instead of listing all the code in the main program, your main program calls the ____.

A) argument
B) parameter
C) module
D) constant
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
28
____ is used to create a program's overall outline and describe tasks to be accomplished, and then details of these tasks are refined later.

A) Cohesion
B) Top-down design
C) Coupling
D) Bottom-up design
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
29
When output is meant for the screen, you should use the ____ keyword.

A) Declare
B) Print
C) Display
D) Input
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
30
When output is meant for a printer, you should use the ____ keyword.

A) Print
B) Input
C) Display
D) Declare
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
31
____ are created when a module is called and exist only while statements in the module are performed.

A) Arguments
B) Global variables
C) Parameters
D) Local variables
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
32
With modular programming, a variable's ____ is the section of program code in which a variable can be accessed.

A) overhead
B) scope
C) coupling
D) cohesion
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
33
____ are available to all modules in the program.

A) Arguments
B) Global variables
C) Local variables
D) Parameters
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
34
In the code below, why is it that the displayName() module cannot print the person's name?
Start
Call getInput()
Call displayName()
Stop
Module getInput()
Declare String name
Display "Enter your name: "
Input name
End Module
Module displayName()
Display "Your name is: " + name
End Module

A) The name variable is outside the displayName() module's scope.
B) The name variable is a global variable.
C) The name variable is strongly cohesive.
D) The name variable has high coupling.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
35
In which of the following is the variable name declared as a global variable?

A) Start
Call getInput()
Call displayName()
Stop
Module getInput()
Declare String name
Display "Enter your name"
Input name
End Module
Module displayName()
Display "Your name is: " + name
End Module

B) Start
Call getInput()
Call displayName()
Stop
Module getInput()
Display "Enter your name"
Input name
End Module
Module displayName()
Declare String name
Display "Your name is: " + name
End Module

C) Start
Call name
Call getInput()
Call displayName()
Stop
Module getInput()
Display "Enter your name"
Input name
End Module
Module displayName()
Declare String name
Display "Your name is: " + name
End Module

D) Start
Declare String name
Call getInput()
Call displayName()
Stop
Module getInput()
Display "Enter your name"
Input name
End Module
Module displayName()
Display "Your name is: " + name
End Module
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
36
Why is it that all variables are not declared as global?

A) Local variables, in different modules, are completely dependent on each other.
B) Local variables are restrictive.
C) By using local variables, programmers working on a module do not have to worry about what variable names are used in the main module or any other module.
D) Global variables, in different modules, are completely dependent on each other.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
37
What happens if a module uses a local variable with the same name as a main module variable, which is assumed to be global?

A) In this case, the variable declared globally is used.
B) It would cause a syntax error.
C) It would cause a logic error.
D) In this case, the variable declared locally is used.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
38
____ are values represented as constants or variables, which are enclosed in the parentheses following the module name in the Call statement.

A) Data types
B) Parameters
C) Data sets
D) Arguments
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
39
Which of the following statements is true?

A) Data types do not need to be declared in function parameters.
B) Modules are designed to accept only one argument.
C) Typically, parameter variable names are longer than variable names in the main module to indicate their permanent nature.
D) Data types must be declared in function parameters.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
40
Sending the value of a variable or constant to a module, where a local variable is initialized to the argument's value is known as ____.

A) passing by value
B) coupling
C) passing by reference
D) cohesion
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
41
When ____, the variable's actual memory address is sent to the module, and the parameter variable is the same location in memory as the variable in the calling module.

A) passing by value
B) cohesion
C) passing by reference
D) coupling
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
42
A ____ error occurs when JavaScript's language rules are violated.

A) global
B) syntax
C) local
D) logic
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
43
A ____ error occurs when the wrong instruction is given to the computer for solving a problem.

A) local
B) syntax
C) global
D) logic
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
44
With a ____ error, the syntax is correct so the computer can process the instruction, but it is not the correct instruction.

A) global
B) syntax
C) local
D) logic
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
45
A ____ is a value that is sent back to the calling module from a called module.

A) return value
B) parameter
C) constructor
D) argument
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
46
____ is the measure of the degree to which all statements and variables in the module relate to one purpose.

A) Coupling
B) Vulnerability
C) Cohesion
D) Efficiency
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
47
____ is the degree to which a module depends on other modules to do its work.

A) Cohesion
B) Coupling
C) Efficiency
D) Vulnerability
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
48
The following function has ____.
Function Numeric average()
// Declare variables
Declare Numeric inputNum // number entered
Declare Numeric quantity // numbers input
Declare Numeric total = 0 // accumulated total
Declare Numeric index // loop variable
Declare Numeric avg // avg of numbers

// Ask user how many numbers to input
Display "How many numbers will you input? "
Input quantity

// Ask user how many numbers to input
Display "How many numbers will you input? "
Input quantity

// Compute and return average, end function
Avg = total / quantity
Return avg
End Function

A) strong cohesion
B) high coupling
C) weak cohesion
D) strong vulnerability
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
49
You might be "____" your code if you write a separate module for every task.

A) over designing
B) overmodularizing
C) over programming
D) strongly coupling
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
50
The prompt() command in JavaScript is actually a(n) ____.

A) variable
B) parameter
C) function
D) argument
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 50 في هذه المجموعة.