Deck 7: Complex Conditions
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/49
Play
Full screen (f)
Deck 7: Complex Conditions
1
Numeric variables can be used to hold values such as "true" and "false" or "yes" and "no."
False
2
The Boolean variable was developed by Tim Berners-Lee, who also developed logical concepts.
False
3
An advantage of the Boolean data type is that when testing a variable's value, a true value is assumed without having to state it.
True
4
When testing to see whether a Boolean variable's value is false, you must include the == True or use the keyword Not in front of the variable.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
5
When testing whether the value of a Boolean variable is true, you do not need to include the relational operator and the value (as in == True) in the condition.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
6
If you are assigning a value to a Boolean variable, you need to include the assignment operator and the value = True or = False.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
7
Conditions are joined with the keyword And or Or.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
8
In JavaScript, a single condition can be negated with the keyword Nor.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
9
In a decision table, you put a dash in cells containing irrelevant conditions and then merge the columns.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
10
Each path on a binary tree leads to another condition that also splits into two paths.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
11
If a condition is irrelevant at some point on a binary tree, it does not need to be split into true and false paths.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
12
A decision table is usually converted into a binary tree.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
13
In JavaScript, the And operator is &.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
14
In JavaScript, the Or operator is //.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
15
In JavaScript, the Not operator is ||.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
16
Conditions in JavaScript are enclosed in parentheses.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
17
The following JavaScript code is a repetition statement.
if (age >= 18 && age <= 65) {
document.write("The age is between 18 and 65." + BR);
}
if (age >= 18 && age <= 65) {
document.write("The age is between 18 and 65." + BR);
}
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
18
When two conditions joined by the logical And operator are evaluated, if the first one is false, there is no need for the computer to evaluate the second one.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
19
If you have statistics on the expected frequency of condition evaluations, you should use them to make your program faster and more efficient.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
20
In the following pseudocode, if any of three conditions evaluates as true, the combined condition is also true.
If code == "SF" Or code == "SP" Or code == "SB" Then
Display "Your order has been shipped."
End If
If code == "SF" Or code == "SP" Or code == "SB" Then
Display "Your order has been shipped."
End If
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
21
Logical operations have a specified order of precedence, just as arithmetic operations do.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
22
In JavaScript, the Or operator takes precedence over And.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
23
In JavaScript, you should use parentheses to make your intentions clear to both the computer and the reader.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
24
When one of the conditions in a complex condition is treated differently than the combined condition, nested conditions result in the clearest logic and the fewest comparisons.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
25
The Math class in JavaScript has the random() method.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
26
A ____ occurs when two or more conditions have to be evaluated for an action to take place.
A) validation loop
B) complex condition
C) short-circuit evaluation
D) dual-outcome selection
A) validation loop
B) complex condition
C) short-circuit evaluation
D) dual-outcome selection
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
27
Which of the following sets of conditions is equivalent?
A) paymentIsOverdue = True
SeniorCitizen = False
B) Declare Boolean paymentIsOverdue Declare Boolean seniorCitizen
C) If paymentIsOverdue
If paymentIsOverdue == True
D) Declare Boolean personHasMoney
Declare Boolean showedID
A) paymentIsOverdue = True
SeniorCitizen = False
B) Declare Boolean paymentIsOverdue Declare Boolean seniorCitizen
C) If paymentIsOverdue
If paymentIsOverdue == True
D) Declare Boolean personHasMoney
Declare Boolean showedID
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
28
The keywords And, Or, and Not, are known as ____.
A) decision tables
B) relational operators
C) logical operators
D) static variables
A) decision tables
B) relational operators
C) logical operators
D) static variables
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
29
Which of the following is considered a dual-outcome selection?
A) If Not balance < 200 Then
Display "Your account will continue to earn interest."
End If
B) If personHasMoney And showedID Then
TicketPrice = discountPrice
Else
TicketPrice = regularPrice
End If
C) If personHasMoney And showedID Then
TicketPrice = discountPrice
End If
D) If password != "sugarBear" Then
Display "Sorry, incorrect password."
End If
A) If Not balance < 200 Then
Display "Your account will continue to earn interest."
End If
B) If personHasMoney And showedID Then
TicketPrice = discountPrice
Else
TicketPrice = regularPrice
End If
C) If personHasMoney And showedID Then
TicketPrice = discountPrice
End If
D) If password != "sugarBear" Then
Display "Sorry, incorrect password."
End If
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
30
Which of the following pseudocode statements express the condition below?
A movie theater admits a customer free if he or she is under 2 years old or if he or she is 65 or older.
A) If age < 65 Or age >=2 Then
AdmissionPrice = 0
Else
AdmissionPrice = regularPrice
B) If age < 2 Or age <= 65 Then
AdmissionPrice = 0
Else
AdmissionPrice = regularPrice
C) If age > 2 Or age < 65 Then
AdmissionPrice = 0
Else
AdmissionPrice = regularPrice
D) If age < 2 Or age >=65 Then
AdmissionPrice = 0
Else
AdmissionPrice = regularPrice
A movie theater admits a customer free if he or she is under 2 years old or if he or she is 65 or older.
A) If age < 65 Or age >=2 Then
AdmissionPrice = 0
Else
AdmissionPrice = regularPrice
B) If age < 2 Or age <= 65 Then
AdmissionPrice = 0
Else
AdmissionPrice = regularPrice
C) If age > 2 Or age < 65 Then
AdmissionPrice = 0
Else
AdmissionPrice = regularPrice
D) If age < 2 Or age >=65 Then
AdmissionPrice = 0
Else
AdmissionPrice = regularPrice
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
31
Which of the following pseudocode statements expresses the condition below?
A hotel customer gets a 10% discount for showing a hotel club card or a travel club card.
A) If showsHotelClubCard And showsTravelClubCard Then
Discount = 0.10
Else
Discount = 0.00
End If
B) If showsHotelClubCard Or showsTravelClubCard Then
Discount = 0.00
Else
Discount = 0.10
End If
C) If showsHotelClubCard Or showsTravelClubCard Then
Discount = 0.10
Else
Discount = 0.00
End If
D) If showsHotelClubCard And showsTravelClubCard Then
Discount = 0.00
Else
Discount = 0.10
End If
A hotel customer gets a 10% discount for showing a hotel club card or a travel club card.
A) If showsHotelClubCard And showsTravelClubCard Then
Discount = 0.10
Else
Discount = 0.00
End If
B) If showsHotelClubCard Or showsTravelClubCard Then
Discount = 0.00
Else
Discount = 0.10
End If
C) If showsHotelClubCard Or showsTravelClubCard Then
Discount = 0.10
Else
Discount = 0.00
End If
D) If showsHotelClubCard And showsTravelClubCard Then
Discount = 0.00
Else
Discount = 0.10
End If
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
32
Which of the following uses the unary logical operator?
A) If password != "sugarBear" Then
Display "Sorry, incorrect password."
End If
B) If showsHotelClubCard Or showsTravelClubCard Then
Discount = 0.10
Else
Discount = 0.00
End If
C) If personHasMoney And showedID Then
TicketPrice = discountPrice
End If
D) If balance >= 200 Then
Display "Your account will continue to earn interest."
End If
A) If password != "sugarBear" Then
Display "Sorry, incorrect password."
End If
B) If showsHotelClubCard Or showsTravelClubCard Then
Discount = 0.10
Else
Discount = 0.00
End If
C) If personHasMoney And showedID Then
TicketPrice = discountPrice
End If
D) If balance >= 200 Then
Display "Your account will continue to earn interest."
End If
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
33
And and Or are called ____ because they operate on two conditions, joining them into a combined condition.
A) unary logical operators
B) relational operators
C) static operators
D) binary logical operators
A) unary logical operators
B) relational operators
C) static operators
D) binary logical operators
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
34
The Not operator, which is placed before a condition to negate it, is a(n) ____ because it operates on a single condition or a single combined condition.
A) unary logical operator
B) relational operator
C) binary logical operator
D) static operator
A) unary logical operator
B) relational operator
C) binary logical operator
D) static operator
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
35
A(n) ____ is a tool for expressing the results of combinations of conditions.
A) flowchart
B) UML diagram
C) truth table
D) logical operator
A) flowchart
B) UML diagram
C) truth table
D) logical operator
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
36
When two conditions are joined by the logical ____ operator, both must be true for the combined condition to be true.
A) Or
B) And
C) Not
D) Equal
A) Or
B) And
C) Not
D) Equal
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
37
A ____ enables you to state all conditions relevant to a decision, the true and false combinations of these conditions, and the outcomes associated with each combination.
A) decision table
B) selection structure
C) repetition structure
D) sequence structure
A) decision table
B) selection structure
C) repetition structure
D) sequence structure
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
38
With a ____, each condition must be stated as a Boolean condition, with only true and false possibilities as answers.
A) UML diagram
B) flowchart
C) selection structure
D) decision table
A) UML diagram
B) flowchart
C) selection structure
D) decision table
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
39
A ____ traces all combinations by starting with one condition and splitting into true and false paths.
A) binary tree
B) relational operator
C) logical operator
D) truth table
A) binary tree
B) relational operator
C) logical operator
D) truth table
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
40
A method for indicating the outcome of combining conditions that appeals to right-brained people is a ____.
A) binary tree
B) selection structure
C) sequence structure
D) repetition structure
A) binary tree
B) selection structure
C) sequence structure
D) repetition structure
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
41
On a binary tree, ____ are used to represent conditions.
A) flowlines
B) ovals
C) diamond boxes
D) process rectangles
A) flowlines
B) ovals
C) diamond boxes
D) process rectangles
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
42
On a binary tree, ____ are used to represent branches.
A) flowlines
B) ovals
C) diamond boxes
D) process rectangles
A) flowlines
B) ovals
C) diamond boxes
D) process rectangles
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
43
On a binary tree, ____ are used to represent outcomes.
A) flowlines
B) ovals
C) diamond boxes
D) process rectangles
A) flowlines
B) ovals
C) diamond boxes
D) process rectangles
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
44
Which of the following represents a negated condition?
A) if (daysOverdue > 10 || fineOwed > 0.00) {
Document.write("Please call the library immediately!"
+ BR);
}
B) if (!(daysOverdue > 10 || fineOwed > 0.00)) {
Document.write("Your account is in good standing." + BR);
}
C) if (age >= 18 && age <= 65) {
Document.write("The age is between 18 and 65." + BR);
}
D) function inquiry(balance) {
Document.write("Your current balance is: $" +
Balance.toFixed(2) + BR);
}
A) if (daysOverdue > 10 || fineOwed > 0.00) {
Document.write("Please call the library immediately!"
+ BR);
}
B) if (!(daysOverdue > 10 || fineOwed > 0.00)) {
Document.write("Your account is in good standing." + BR);
}
C) if (age >= 18 && age <= 65) {
Document.write("The age is between 18 and 65." + BR);
}
D) function inquiry(balance) {
Document.write("Your current balance is: $" +
Balance.toFixed(2) + BR);
}
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
45
Which of the following represents an example of data validation?
A) if (daysOverdue > 10 || fineOwed > 0.00) {
Document.write("Please call the library immediately!"
+ BR);
}
B) if (!(daysOverdue > 10 || fineOwed > 0.00)) {
Document.write("Your account is in good standing." + BR);
}
C) if (age >= 18 && age <= 65) {
Document.write("The age is between 18 and 65." + BR);
}
D) while (!(month >= 1 && month <= 12)) {
Month = prompt
("ERROR...Enter a number between 1 and 12",ES);
}
A) if (daysOverdue > 10 || fineOwed > 0.00) {
Document.write("Please call the library immediately!"
+ BR);
}
B) if (!(daysOverdue > 10 || fineOwed > 0.00)) {
Document.write("Your account is in good standing." + BR);
}
C) if (age >= 18 && age <= 65) {
Document.write("The age is between 18 and 65." + BR);
}
D) while (!(month >= 1 && month <= 12)) {
Month = prompt
("ERROR...Enter a number between 1 and 12",ES);
}
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
46
A(n) ____ is a process that does not evaluate the second condition of a combined condition if evaluation of the first condition determines the outcome.
A) logical evaluation
B) unary evaluation
C) short-circuit evaluation
D) binary evaluation
A) logical evaluation
B) unary evaluation
C) short-circuit evaluation
D) binary evaluation
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
47
A(n) ____ is used when you need one action performed when the combined condition is true and another action performed when the combined condition is false.
A) truth table
B) complex condition
C) nested condition
D) short-circuit evaluation
A) truth table
B) complex condition
C) nested condition
D) short-circuit evaluation
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
48
Which of the following generates a random number between 0 and 1?
A) var randomNum = Math.random();
Document.write(randomNum);
B) var randomNum = Calculate.random();
Document.write(randomNum);
C) var randomNum = Number.random();
Document.write(randomNum);
D) var randomNum = Math.randomNumber();
Document.write(randomNum);
A) var randomNum = Math.random();
Document.write(randomNum);
B) var randomNum = Calculate.random();
Document.write(randomNum);
C) var randomNum = Number.random();
Document.write(randomNum);
D) var randomNum = Math.randomNumber();
Document.write(randomNum);
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
49
Which of the following generates a random number between 0 and 10?
A) var randomNum = Math.random() * 10;
RandomNum = Math.floor(randomNum)+ 1;
Document.write(randomNum);
B) var randomNum = Calculate.random() * 10;
Document.write(randomNum);
C) var randomNum = Number.random() * 10;
Document.write(randomNum);
D) var randomNum = Math.randomNumber() * 10;
Document.write(randomNum);
A) var randomNum = Math.random() * 10;
RandomNum = Math.floor(randomNum)+ 1;
Document.write(randomNum);
B) var randomNum = Calculate.random() * 10;
Document.write(randomNum);
C) var randomNum = Number.random() * 10;
Document.write(randomNum);
D) var randomNum = Math.randomNumber() * 10;
Document.write(randomNum);
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck