Making Decisions Flashcards

1
Q

What is the term used to describe this?

  • value can be only true or false
  • used in every selection structure

EVALUATING BOOLEAN EXPRESSIONS TO MAKE COMPARISONS

A

Boolean Expression

EVALUATING BOOLEAN EXPRESSIONS TO MAKE COMPARISONS

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

What is the term used to describe this?

  • alternative(or binary) selection structure
  • provides an action for each of two possible outcomes

EVALUATING BOOLEAN EXPRESSIONS TO MAKE COMPARISONS

A

Dual

EVALUATING BOOLEAN EXPRESSIONS TO MAKE COMPARISONS

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

What is the term used to describe this?

  • alternative (or unary) selection structure
  • action is provided for only one outcome
  • if - then

EVALUATING BOOLEAN EXPRESSIONS TO MAKE COMPARISONS

A

Single

EVALUATING BOOLEAN EXPRESSIONS TO MAKE COMPARISONS

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

What is the term used to describe this?

Holds the action or actions that execute when
the tested condition in the decision is true

EVALUATING BOOLEAN EXPRESSIONS TO MAKE COMPARISONS

A

then clause

EVALUATING BOOLEAN EXPRESSIONS TO MAKE COMPARISONS

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

What is the term used to describe this?

Executes only when the tested condition in
the decision is false

EVALUATING BOOLEAN EXPRESSIONS TO MAKE COMPARISONS

A

else clause

EVALUATING BOOLEAN EXPRESSIONS TO MAKE COMPARISONS

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

What is the term used to describe this?

  • Six types supported by all modern programming
    languages
  • Each of these operators is Binary, each requires
    two operands

4 = 4 100 <= 99

USING THE RELATIONAL COMPARISON OPERATORS

A

Relational Comparison Operators

USING THE RELATIONAL COMPARISON OPERATORS

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

What is the term used to describe this?

  • Two values compared can be either variables or
    constants
    CurrentTotal = 100
    Variables = numeric constant

USING THE RELATIONAL COMPARISON OPERATORS

A

Relational Comparison Operators

USING THE RELATIONAL COMPARISON OPERATORS

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

What is the term used to describe this?

  • Two values compared can be either variables or
    constants
    CurrentTotal = 100
    Variables = numeric constant

USING THE RELATIONAL COMPARISON OPERATORS

A

Relational Comparison Operators

USING THE RELATIONAL COMPARISON OPERATORS

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

What is the term used to describe this?

Each will always evaluate to the same result
Example:
20 = 20?
40 = 30?

USING THE RELATIONAL COMPARISON OPERATORS

A

Trivial Expressions

USING THE RELATIONAL COMPARISON OPERATORS

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

What is the term used to describe this?

Each will always evaluate to the same result
Example:
20 = 20?
40 = 30?

USING THE RELATIONAL COMPARISON OPERATORS

A

Trivial Expressions

USING THE RELATIONAL COMPARISON OPERATORS

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

What is the term used to describe this?

OPERATOR NAME DISCUSSION

EVALUATES AS TRUE WHEN ITS OPERANDS
ARE EQUIVALENTS. MANY LANGUAGES USE A
DOUBLE EQUAL SIGN (==) TO AVOID
CONFUSION WITH THE ASSIGNMENT
OPERATOR

USING THE RELATIONAL COMPARISON OPERATORS

A

= EQUIVALENCY OPERATOR

USING THE RELATIONAL COMPARISON OPERATORS

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

What is the term used to describe this?

OPERATOR NAME DISCUSSION

EVALUATES AS TRUE WHEN ITS OPERANDS
ARE EQUIVALENTS. MANY LANGUAGES USE A
DOUBLE EQUAL SIGN (==) TO AVOID
CONFUSION WITH THE ASSIGNMENT
OPERATOR

USING THE RELATIONAL COMPARISON OPERATORS

A

= EQUIVALENCY OPERATOR

USING THE RELATIONAL COMPARISON OPERATORS

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

What is the term used to describe this?

OPERATOR NAME DISCUSSION

EVALUATES AS TRUE WHEN THE LEFT
OPERAND IS GREATER THAN THE RIGHT
OPERAND

USING THE RELATIONAL COMPARISON OPERATORS

A

> GREATER-THAN OPERATOR

USING THE RELATIONAL COMPARISON OPERATORS

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

What is the term used to describe this?

OPERATOR NAME DISCUSSION

EVALUATES AS TRUE WHEN THE LEFT
OPERAND IS LESS THAN THE RIGHT
OPERAND.

USING THE RELATIONAL COMPARISON OPERATORS

A

< LESS-THAN
OPERATOR

USING THE RELATIONAL COMPARISON OPERATORS

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

What is the term used to describe this?

EVALUATES AS TRUE WHEN THE LEFT
OPERAND IS GREATER THAN OR EQUIVALENT
TO THE RIGHT OPERAND

USING THE RELATIONAL COMPARISON OPERATORS

A

> = GREATER-THAN
OR EQUAL-TO
OPERATOR

USING THE RELATIONAL COMPARISON OPERATORS

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

What is the term used to describe this?

EVALUATES AS TRUE WHEN THE LEFT
OPERAND IS LESS THAN OR EQUIVALENT TO
THE RIGHT OPERAND.

USING THE RELATIONAL COMPARISON OPERATORS

A

<= LESS-THAN OR
EQUAL-TO
OPERATOR

USING THE RELATIONAL COMPARISON OPERATORS

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

What is the term used to describe this?

EVALUATES AS TRUE WHEN ITS OPERANDS ARE NOT EQUIVALENT.

SOME LANGUAGES USE AN
EXCLAMATION POINT FOLLOWED BY AN EQUAL

SIGN TO INDICATE NOT EQUAL TO OPERATOR DIFFERS IN THE COMMON PROGRAMMING LANGUAGES, THIS BOOK WILL MOST OFTEN SPELL OUT “IS NOT EQUAL TO” IN FLOWCHARTS
AND PSEUDOCODE.

USING THE RELATIONAL COMPARISON OPERATORS

A

<> NOT-EQUAL TO OPERATOR

USING THE RELATIONAL COMPARISON OPERATORS

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

What is the term used to describe this?

EVALUATES AS TRUE WHEN ITS OPERANDS ARE NOT EQUIVALENT. SOME LANGUAGES USE AN
EXCLAMATION POINT FOLLOWED BY AN EQUAL
SIGN TO INDICATE NOT EQUAL TO OPERATOR
DIFFERS IN THE COMMON PROGRAMMING
LANGUAGES, THIS BOOK WILL MOST OFTEN
SPELL OUT “IS NOT EQUAL TO” IN FLOWCHARTS
AND PSEUDOCODE.

USING THE RELATIONAL COMPARISON OPERATORS

A

<> NOT-EQUAL TO OPERATOR

USING THE RELATIONAL COMPARISON OPERATORS

19
Q

True or False?

Any logical situation can be expressed with only
three types of comparisons: = , > , and <
– Operators >= and <= are not necessary but
make code more readable and convenient.

USING THE RELATIONAL COMPARISON OPERATORS

A

True

USING THE RELATIONAL COMPARISON OPERATORS

20
Q

What are the 2 Common Errors with relational operators?

AVOIDING A COMMON ERROR WITH RELATIONAL OPERATORS

A
  • Using the wrong operator
  • Missing the boundary or limit required for a
    selection

AVOIDING A COMMON ERROR WITH RELATIONAL OPERATORS

21
Q

What is the term used to describe this?

Asks multiple questions before an outcome is
determined
Example:
> The basic monthly service bill is $30.00
> An additional $20.00 is billed to customers who
make more than 100 calls that last for a total of
more than 500 minutes.

UNDERSTANDING AND LOGIC

A

Compound condition

UNDERSTANDING AND LOGIC

22
Q

What is the term used to describe this?

Which two conditions must be true for an action
to take place.
Requires that both of two tests evaluate to true
Requires a nested decision (nested if)
a decision “inside of” another decision.

UNDERSTANDING AND LOGIC

A

AND decision

UNDERSTANDING AND LOGIC

23
Q

What is the term used to describe this?

You must decide which of the two decision to make first.
Logically, either selection in an AND decision can come first.
Performance time can be improved by asking questions in the proper order

NESTING AND DECISIONS FOR EFFICIENCY

A

When nesting decisions

NESTING AND DECISIONS FOR EFFICIENCY

24
Q

What is the term used to describe this?

In an AND decision, first ask the question that is blank likely to be true
- Eliminates as many instances of the second
decision as possible
- Speeds up processing time

UNDERSTANDING AND LOGIC

A

Less likely

UNDERSTANDING AND LOGIC

25
Q

What is the term used to describe this?

  • Ask two or more questions in a single
    comparison
  • Each Boolean expression must be true for entire
    expression to evaluate to true
  • if either part of the expression is false, then the
    entire expression is false.

USING THE AND OPERATOR

A

Conditional AND operator

USING THE AND OPERATOR

26
Q

What is the term used to describe this?

  • Describe the truth of an entire expression based
    on the truth of its parts

USING THE AND OPERATOR

A

Truth tables

USING THE AND OPERATOR

27
Q

What is the term used to describe this?

  • Describe the truth of an entire expression based
    on the truth of its parts

USING THE AND OPERATOR

A

Truth tables

USING THE AND OPERATOR

28
Q

What is the term used to describe this?

  • the question you place first (to the left of the
    operator) is the one that will be asked first, and
    cases that are eliminated based on the first
    question will not proceed to the second
    questions

USING THE AND OPERATOR

A

Short-circuit evaluation

USING THE AND OPERATOR

29
Q

What is the term used to describe this?

  • Make sure that the second decision must be made
    entirely within the first decision.
    You can surround each blank expression in a
    compound expression with its own set of parenthesis
If (callsMade > CALLS)AND (callMnutes > Minutes) then
customerBill = customerBill + Premium
endIf

AVOIDING COMMON ERRORS IN AN AND SELECTION

A

Boolean

AVOIDING COMMON ERRORS IN AN AND SELECTION

30
Q

What is the term used to describe this?

Take action when one or the other of two
conditions is true
Example
~~~
“Are you free for dinner Friday or Saturday?”
Add $20 to the bills who either make more than
100 calls OR use more than 500 minutes
~~~

UNDERSTANDING OR LOGIC

A

OR decision

UNDERSTANDING OR LOGIC

31
Q

What is the term used to describe this?

  • May ask either question first
    Both produce the same output but vary widely in
    number of questions asked
  • If first question is blank , no need to ask second

WRITING OR DECISIONS FOR EFFICIENCY

A

True

WRITING OR DECISIONS FOR EFFICIENCY

32
Q

What is the term used to describe this?

  • In an blank , first ask the question that is
    more likely to be true
    Eliminates as many repetitions as possible of
    second decision
    The time it takes to process all the data is
    decreased.

WRITING OR DECISIONS FOR EFFICIENCY

A

OR decision

WRITING OR DECISIONS FOR EFFICIENCY

33
Q

What is the term used to describe this?

  • Ask two or more questions in a single comparison
  • Only one Boolean expression in an OR selection must be
  • true to produce a result of true
  • Question placed first will be asked first
  • Consider efficiency
  • Computer can ask only one question at a time

WRITING OR DECISIONS FOR EFFICIENCY

A

Conditional OR operator

WRITING OR DECISIONS FOR EFFICIENCY

34
Q

What is the term used to describe this?

Avoiding Common Errors in an OR Selection
Second question
must be blank structure
with one entry and
exit point

WRITING OR DECISIONS FOR EFFICIENCY

A

Self-contained

WRITING OR DECISIONS FOR EFFICIENCY

35
Q

What is the term used to describe this?

Request for A and B in English often translates to a
request for A or B blank
Example
“Give a bonus to anyone who has sold at least
three items and to anyone who has sold $2000”
“Give a bonus to anyone who has sold at least
three items or $200

MAKING SELECTIONS WITHIN RANGES

A

Logically

MAKING SELECTIONS WITHIN RANGES

36
Q

What is the term used to describe this?

Compare a variable to a
series of values between
limits

MAKING SELECTIONS WITHIN RANGES

A

Range Check

MAKING SELECTIONS WITHIN RANGES

37
Q

What is the term used to describe this?

Use the lowest or highest value in each range
Adjust the blank when using highest versus
lowest values
Should end points of the range be included?
Yes: use >= or <=
No: use < or >

MAKING SELECTIONS WITHIN RANGES

A

Question logic

MAKING SELECTIONS WITHIN RANGES

38
Q

What is the term used to describe this?

Avoid blank paths
* Don’t check for values that can never occur
* Requires some prior knowledge of the data

AVOIDING COMMON ERRORS WHEN USING RANGE CHECKS

A

Dead or unreachable

AVOIDING COMMON ERRORS WHEN USING RANGE CHECKS

39
Q

What is the term used to describe this?

Never ask a question if there is only one possible blank
Avoid asking a question when the logic has already determined the blank

AVOIDING COMMON ERRORS WHEN USING RANGE CHECKS

A

Outcome

AVOIDING COMMON ERRORS WHEN USING RANGE CHECKS

40
Q

True or False?

When only one of multiple conditions must be true,
use multiple ORs

if score1 >= 75 OR score2 >= 75 OR 
score3 >= 75 then
classGrade = “Pass”
else
classGrade = “Fail”
endif

UNDERSTANDING PRECEDENCE WHEN COMBINING AND AND OR SELECTIONS

A

True

UNDERSTANDING PRECEDENCE WHEN COMBINING AND AND OR SELECTIONS

41
Q

True or False?

When only one of multiple conditions must be true,
use multiple ORs

if score1 >= 75 OR score2 >= 75 OR 
score3 >= 75 then
classGrade = “Pass”
else
classGrade = “Fail”
endif

UNDERSTANDING PRECEDENCE WHEN COMBINING AND AND OR SELECTIONS

A

True

UNDERSTANDING PRECEDENCE WHEN COMBINING AND AND OR SELECTIONS

42
Q

True or False?

When AND and OR operators are combined in the
same statement, AND operators are evaluated first
~~~
if age <= 12 OR age >= 65 AND rating
= “G”
~~~

UNDERSTANDING PRECEDENCE WHEN COMBINING AND AND OR SELECTIONS

A

True

UNDERSTANDING PRECEDENCE WHEN COMBINING AND AND OR SELECTIONS

43
Q

True or False?

Mixing AND and OR operators makes logic more
complicated
Can avoid mixing AND and OR decisions by nesting
if statements

UNDERSTANDING PRECEDENCE WHEN COMBINING AND AND OR SELECTIONS

A

True

UNDERSTANDING PRECEDENCE WHEN COMBINING AND AND OR SELECTIONS