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.
The Boolean expression placed first (to the left of the AND operator) is the one that will be evaluated first. That means that cases that are eliminated based on the first evaluation will NOT proceed to the second one. This built-in feature of many programming languages is called….
short-circuit evaluation.
These are diagrams used in mathematics and logic to help describe the truth of an entire expression based on the truth of its parts.
Truth tables
Computers make decisions one at a time, from _____ to ______.
left to right
What are the 3 benefits to using AND operators instead of nested/cascading if statements?
- more concise.
- less error-prone
- easier to understand
in an OR decision, either one condition or some other condition must be met in order for….
the evaluation to return as True and some action begins to take place.
It is better to evaluate the condition that is more likely to be true first in an ___ _______.
OR decision
the OR operator is also called the ______ OR operator.
Conditional
When x OR y are each false individually, the entire expression is read as….
False.
The NOT operator ______ the meaning of a Boolean expression.
reverses
the NOT operator is a ______ operator.
unary
You do not use these in between two expressions; rather, you use it in front of a single expression.
unary operators
This compares a variable to a series of values that mark the limiting ends of _____.
range check; ranges.
another phrase for a path that is “dead”
unreachable path
When you combine AND and OR operators within the same statement, the AND operators take ________.
precedence; their Boolean values are evaluated first.
You can alter the computer’s intuitive logic of giving an AND operator’s value precedence by using _______ around the OR expression.
parentheses
A _____ Boolean expression is one that always has the same value.
trivial
If x <= y is True, then x __ y is False.
>
What does the following mean? if x > 10 then if y > 10 then output "X" endif endif
if x > 10 AND y > 10 then output “X”