- control flow: gives us the ability to choose among outcomes based off what else is happening in the program
- there are six comparators:
- equal to (==)
- not equal to (!=)
- less than (<)
- less than or equal to (<=)
- greater than (>)
- greater than or equal to (>=)
- comparisons result in either true or false, like booleans
- boolean operators compare statements and result in boolean values
- there are three boolean operators:
- (and), which checks if both statements are (true)
- (or), which checks if at least one statement is true
- (not), which gives the opposite of the statement
- order of operations for boolean operators
- (not) is evaluated first
- (and) is evaluated next
- (or) is evaluated last
- anything in parenthesis is evaluated as its own unit
- conditional statement syntax
- (if) is a conditional statement that executes some specified code after checking if its expression is (true)
- if some_function():
- indented block of code after it will be executed
- if 3 + 2 == 5:
- else problems
- complements (if) statements
- (if) x is true, run this code, (else) "otherwise" run this code
- doesn't depend on an expression, unlike (if)
- if 8 < 9:
- else:
- elif
- short for "else if"
- means: otherwise, if the following expression is true, do this
nov 28 2014 ∞
apr 19 2015 +