- How can my programs do different things based on data values?
- Understand "expressions" and booleans.
- Write conditional statements including
- Correctly evaluate expressions containing
- Understand "boolean indexing" with regard to NumPy arrays.
Please use the Jupyter notebook named "05MakingChoices.ipynb" for this lesson. If you haven't downloaded them already, you may find them here.
if condition to start a conditional statement,
elif condition to provide additional tests, and
else to provide a default.
- The bodies of the branches of conditional statements must be indented.
== to test for equality.
X and Y is only true if both
X or Y is true if either
Y, or both, are
- Zero, the empty string, and the empty list are considered false; all other numbers, strings, and lists are considered true.
False represent truth values.