Branching Part 2 Flashcards

1
Q

Logical AND (2)

How to get to true and how to get to false

A
  • ALl expression must evaluate to true before the entire expression is true
  • If any expression is false then whole expression evaluates to false
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Logical OR (2)

How to get to true and how to get to false

A
  • If any Boolean expresion evaluates to true then the entire expression evaluates to true
  • All Boolean expressions must evaluate to false before the entire expression is false
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Logical NOT

may be expression by

A
  • May be replaced by the use of an inequality operator
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Nested Branches (3)

How it works+ex for type+ex content

A
  • An IF-branch that is inside of another IF-branch
  • Only when users specifies the residence as ALberta does the program ask for which city
  • The nested branch is only checked if the first branch’s Boolean expression evaluates to true
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Nested Desicion Making (2)

The format and how to get inner desicion to be executed?

A
  • One desicion is made inside another
  • Outer desicions must evaluate to true before inner desicions are even considered for evaluation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Why should you not use editor with diff font sizes?

A

Extra info will introduce syntax errors

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

Desicion Making with multiple IFS (2)
Later questions+ employed when…

A
  • Later questions (IF) always asked regardless of previous questions.
  • Employed when a series of independent questions will be asked
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When to use multiple “Ifs”? (3)

The condition+ question and ans relationship+Boolean expression

A

-non-exclusive conditions (multiple conditions or options can be true/ not excclusive)
The questions are independent and the ans does not affect the next question
- More than one Boolean expressions for each if can be true

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

Why to not use multiple IFs (3)

A

ineffiecient because later Boolean expressions may be evaluated needlessly
- specifying a sequence of independent conditions can be less optimal when at most only 1 condition can be true
- For ex use If-Elise-Else as if one of the earlier “if/elise” are true the trest arent evaluated.

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

Multiple If-Elif-Else (2)

How it works/what if false?+Ex

A
  • One condition evaluating to true excludes other conditions from being true (The ifs that come later are only evaluated if the earlier “ifs” evaluated to false)
  • Example, having current location as calgary excludes the possibility of the current location as Edmonton, Toronto, Medicine Hat
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

When is nesting needed?

A

When you have a dealbreaker. The outer Boolean expression (gatekeeper) must be true before the inner expression will be evaluated.

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

When to use nested IF vs IF-AND?

A

When you want one consition to evaluate to true and do something even if second is False.

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

We dont execute Boolean body of an IF unless

A

expression evaluates to true

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

IF-Else

A

Checks conditions and executes one body of code if the condition is true and aother is the condition is false

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

Descision making with multiple IFs, the later questions are

Non exclusive conditions

A

always asked regardless of previous questions

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

Multiple IF-Elif-ELse are used with________ conditions

A

mutually exclusive conditions

17
Q

Mutally exclusive

A

One condition evaluating to true excludes other conditions from being true

18
Q

When to use If- elif? + also allows what? (2)

A
  • multiple Boolean expression need to be evaluated but at most only 1 Boolean expression can be evaluated to true
  • Also allows for a seperate body (else) to execute when all the if-elif expressions are false
19
Q

When to use compound desicion making?

A

There may have to be more than 1 condition to be considered before the body can execute. All expression must evaluate to True (AND) or at least one must be true (OR)

20
Q

dealbreaker/ gatekeepers are in

A

Nested expressions

21
Q

Why do we avoid using a float when an integer will do?

A

floating points are approximations of real numbers and are not stored as exact values. If you use an operator (>=) it has ro be exact, close enought does not work.