1/18
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Flow control
The order of statement execution
Linear: one statement after another
By default, execution of code is
Boolean/condition expressions
Selection or decision statements are based on
None and False
Zero of any Numeric types (0, 0.0, 0j, etc.)
Empty Sequences
What is always False with boolean expressions (3)
if
elif
else
switch
Types of Selection/Conditional statements (4)
if
Block of code executes if a boolean expression is true. If the boolean expression is false, the block of code is skipped
elif
Must come under if or an elif. It will execute its block of code if the boolean expression is true and if the if/elif it is attached to evaluates to False
else
Must come under an if or elif and only one can be present per if block. It will execute if the if and all precending elif (if present) evaluate to False
switch
Lets the value of a variable determine where the program will branch to
Logical NOT
Logical AND
Logical OR
Boolean expressions can also use the following logical operators (3)
Logical NOT (logical negation, logical complement)
A unary operator that operates one operand
Logical AND and OR
Binary operators that operate on two operands
Mathematical operators have higher precedence than the relational and logical operators
Relational operators have higher precedence than logical operators
Precedence rules with Logical operators in boolean expressions (2)
Necessary
In python, indentation is
Nested if
An if statement can be put inside another if statement where the second if will be evaluated only if the first if evaluates to true
match
Provides another way to decide which statement to execute next and uses a variable and attempts to match the value to one of several possible cases
Case
Contains a value and a list of statements
Default case
A match statement can have an optional case that uses an underscore. If this is present, control will transfer to the default case if no other case value matches
Falls through to the statement after the switch statement
If there is no default case, and no other value matches control…