Chapter 4 (Decision-Making) Flashcards

1
Q

The ________ structure starts with the evaluation of a ________ expression, and takes one of two paths, based on the outcome of that evaluation.

A

selection; Boolean

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

selection statements that execute when condition is true begin with __ ___

A

if then

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Else statements begin a path execution for when a _______ is false.

A

condition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

The if keyword is also called an if-then _____.

A

clause

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Are else clauses required to be consequent after an if-then clause?

A

No, they are not required.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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.

A

Relational comparison operators

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

This evaluates as true when its operands are equivalent.

A

Equivalency operator ( = )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is this <> called?

A

Not-equal-to operator.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Both operands in a comparison expression must be the same…

A

data type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

In any comparison, the two values can be either ______ or _______.

A

variables or constants

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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.

A

Trivial expressions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Are trivial expressions legal?

A

Yes. They are legal, but redundant.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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)

A

trivial expression.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the two reasons why would the comparison “black” < “blue” return as true?

A
  1. They are the same data type (string), so comparing them is legal.
  2. “black” precedes “blue” alphabetically.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

String variables can only be considered equal if they are _______, including the spacing and case-sensitivity attributes (uppercase vs. lowercase)

A

identical

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

!= is another way of displaying which operator?

A

The not-equal-to operator ( <> )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What is it called when you make multiple evaluations before an outcome is determined?

A

“Compound condition”

18
Q

A decision that uses an AND expression can be constructed using a…..

A

nested decision.

19
Q

What is another phrase for a series of nested if statements?

A

a “Cascading If statement”

20
Q

In an AND decision, it is best to first evaluation the condition that is less likely to be ____

21
Q

Why is it better to evaluate the condition that is less likely to be true first in an AND decision?

A

Because it eliminates as many instances of the second decision as possible, thus speeding up processing time.

22
Q

A conditional AND operator is the same as a….

A

AND operator

23
Q

an AND operator allows you to ask how many questions in a single comparison/expression?

A

two or more

24
Q

When you use one or more AND operators to combine two or more Boolean expressions, each Boolean expression must be true for…

A

the entire expression to be evaluated as true. Both conditions must return as TRUE or YES.

25
Q

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….

A

short-circuit evaluation.

26
Q

These are diagrams used in mathematics and logic to help describe the truth of an entire expression based on the truth of its parts.

A

Truth tables

27
Q

Computers make decisions one at a time, from _____ to ______.

A

left to right

28
Q

What are the 3 benefits to using AND operators instead of nested/cascading if statements?

A
  1. more concise.
  2. less error-prone
  3. easier to understand
29
Q

in an OR decision, either one condition or some other condition must be met in order for….

A

the evaluation to return as True and some action begins to take place.

30
Q

It is better to evaluate the condition that is more likely to be true first in an ___ _______.

A

OR decision

31
Q

the OR operator is also called the ______ OR operator.

A

Conditional

32
Q

When x OR y are each false individually, the entire expression is read as….

33
Q

The NOT operator ______ the meaning of a Boolean expression.

34
Q

the NOT operator is a ______ operator.

35
Q

You do not use these in between two expressions; rather, you use it in front of a single expression.

A

unary operators

36
Q

This compares a variable to a series of values that mark the limiting ends of _____.

A

range check; ranges.

37
Q

another phrase for a path that is “dead”

A

unreachable path

38
Q

When you combine AND and OR operators within the same statement, the AND operators take ________.

A

precedence; their Boolean values are evaluated first.

39
Q

You can alter the computer’s intuitive logic of giving an AND operator’s value precedence by using _______ around the OR expression.

A

parentheses

40
Q

A _____ Boolean expression is one that always has the same value.

41
Q

If x <= y is True, then x __ y is False.

42
Q
What does the following mean?
if x > 10 then
    if y > 10 then
        output "X"
    endif
endif
A

if x > 10 AND y > 10 then output “X”