Chapter 4 (Decision-Making) Flashcards
The ________ structure starts with the evaluation of a ________ expression, and takes one of two paths, based on the outcome of that evaluation.
selection; Boolean
selection statements that execute when condition is true begin with __ ___
if then
Else statements begin a path execution for when a _______ is false.
condition
The if keyword is also called an if-then _____.
clause
Are else clauses required to be consequent after an if-then clause?
No, they are not required.
These are binary operators (like arithmetic operators). They require 2 operands. They apply arithmetic symbols, but are used in selection structures rather than a literal mathematical formula.
Relational comparison operators
This evaluates as true when its operands are equivalent.
Equivalency operator ( = )
What is this <> called?
Not-equal-to operator.
Both operands in a comparison expression must be the same…
data type.
In any comparison, the two values can be either ______ or _______.
variables or constants
This describes an expression that always evaluates to the same value. Because it will always return true, or always return false, it is a waste of processing power and logically redundant.
Trivial expressions.
Are trivial expressions legal?
Yes. They are legal, but redundant.
Assigning an unnamed literal constant to another unnamed literal constant, or comparing the two for a Boolean output, is an example of a _______ _________.
(i.e. 30 = 40)
trivial expression.
What are the two reasons why would the comparison “black” < “blue” return as true?
- They are the same data type (string), so comparing them is legal.
- “black” precedes “blue” alphabetically.
String variables can only be considered equal if they are _______, including the spacing and case-sensitivity attributes (uppercase vs. lowercase)
identical
!= is another way of displaying which operator?
The not-equal-to operator ( <> )
What is it called when you make multiple evaluations before an outcome is determined?
“Compound condition”
A decision that uses an AND expression can be constructed using a…..
nested decision.
What is another phrase for a series of nested if statements?
a “Cascading If statement”
In an AND decision, it is best to first evaluation the condition that is less likely to be ____
true.
Why is it better to evaluate the condition that is less likely to be true first in an AND decision?
Because it eliminates as many instances of the second decision as possible, thus speeding up processing time.
A conditional AND operator is the same as a….
AND operator
an AND operator allows you to ask how many questions in a single comparison/expression?
two or more
When you use one or more AND operators to combine two or more Boolean expressions, each Boolean expression must be true for…
the entire expression to be evaluated as true. Both conditions must return as TRUE or YES.