Lecture 3 - Decision Structures and Boolean Logic Flashcards
What does sequential order describe?
Describes order in which statements are executed top to bottom (executed in the textual order they appear within the program)
What is a selection statement?
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.
What is control structure?
logical design that determines the order in which a set of statements (or a set of statement sequences) will execute
In python what does the ‘if’ statement determine?
whether or not the action associated with the statement(s) can be executed
What is a single alternative decision structure?
Either the action is performed (when the condition is True) or it is not performed (when the condition is False).
How is ‘if’ represented in a flowchart?
by a diamond
What are boolean expressions?
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.
What is a relational operator?
Determines whether or not a specific kind of ordering (i.e., a relation) exists between two operands
What are some examples of relational operators?
< less than > greater than <= less than or equal to >= greater than or equal to == equals != doesn't equal (not equal)
What is the syntax of the ‘if’ statement?
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).
What is the ‘if-else’ statement?
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.
What is the simplest boolean operator?
‘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.
What is the result of the boolean operator ‘and’ ?
Result is True only if both operands are True, and is False otherwise.
How do we usually describe the results of boolean operators?
in the form of truth tables
How many boolean operands does the operator ‘and’ need?
Takes two boolean operands