Lecture 3 - Decision Structures and Boolean Logic Flashcards

1
Q

What does sequential order describe?

A

Describes order in which statements are executed top to bottom (executed in the textual order they appear within the program)

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

What is a selection statement?

A

Used to determine which of several actions to be taken given the value of some condition also known as selection structure or decision structure or conditionals.

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

What is control structure?

A

logical design that determines the order in which a set of statements (or a set of statement sequences) will execute

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

In python what does the ‘if’ statement determine?

A

whether or not the action associated with the statement(s) can be executed

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

What is a single alternative decision structure?

A

Either the action is performed (when the condition is True) or it is not performed (when the condition is False).

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

How is ‘if’ represented in a flowchart?

A

by a diamond

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

What are boolean expressions?

A

Situations (i.e., conditions) examined by the if statement are themselves expressions that evaluate to true or false.
These expressions are called boolean expressions.
They often involve the use of one or more relational operators.

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

What is a relational operator?

A

Determines whether or not a specific kind of ordering (i.e., a relation) exists between two operands

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

What are some examples of relational operators?

A
< less than
> greater than
<= less than or equal to
>= greater than or equal to
== equals
!= doesn't equal (not equal)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the syntax of the ‘if’ statement?

A

The first line includes the keyword ‘if’ this is followed by the boolean (i.e., True or False) expression, lastly there is an indented sequences of statements known as a block.
When the expression evaluates to True, all statements in the block are executed.
When the expression evaluates to False, no statement in the block is executed (i.e., all statements are skipped).

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

What is the ‘if-else’ statement?

A

This enables two possible paths of execution and guarantees that exactly one of the paths will be taken.
One path is followed when the if-condition is True and the other path is followed when the if-condition is False.
The False path is indicated by the block following the else keyword.

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

What is the simplest boolean operator?

A

‘not’
The simplest boolean operator as it takes a single boolean operand.
If its operand is True, the result is False.
If its operand is False, the result is True.

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

What is the result of the boolean operator ‘and’ ?

A

Result is True only if both operands are True, and is False otherwise.

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

How do we usually describe the results of boolean operators?

A

in the form of truth tables

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

How many boolean operands does the operator ‘and’ need?

A

Takes two boolean operands

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

How many boolean operands does the operator ‘or’ need?

A

Takes two boolean operands

17
Q

What is the result of the boolean operator ‘or’ ?

A

Result is True if either operand is True, and is False otherwise.

18
Q

What is the logical ‘and’ sometimes represented as?

A

Logical ‘and’ is sometimes called conjunction and in mathematics is represented by the ∧ symbol.

19
Q

What is the logical ‘or’ sometimes represented as?

A

Logical ‘or’ is sometimes called disjunction and in mathematics is represented by the ∨ symbol.

20
Q

What is a common use of boolean operators?

A

constructing range checks

e. g., Is some number within a range of low and high values?
e. g., Or is the value outside of that range?

21
Q

What are flags?

A

The results of boolean expressions may be assigned to variables. Such a variable then has a reference to True or False.
Sometimes such variables are very handy when creating flags.
Flags are used by other parts of the program to determine further action.

22
Q

What are the three main conditional statements?

A

‘if’, ‘if-else’ and ‘if-elif-else’.

23
Q

What can be used to express conditions for checking at execution time?

A

Relational operators and boolean operators