Selection Flashcards
Selection
Making choices in the flow of execution of a program
Selections are made on the basis of ________ expressions
boolean (evaluate to true or false)
Nested ‘if’ statement
If statement within an if statement
Dangling else problem does not apply in python because…
‘if’-‘else’ association is determined by indent level
Multiway selection
Multiple conditions, each of which causes a different block of statements to execute
Used when there are more than 2 options
Booleans
Binary value that has only two possible states - True or False
3 boolean operators
and, or, not
De Morgan’s Laws
Two transformation laws for simplifying expressions involving boolean algebra:
not(A or B) = not A and not B
not(A and B) = not A or not B
Conditional expression
Expression that compares values using conditional operators (< , > , == , etc.)
Evaluate to boolean