- Introduction to Python
- Python: Choosing a Text Editor or IDE
- Python: Hello World
- Python: Variables, Strings and Numbers
- Python: Variable Naming
- Python: Math, Familiar
- Python: Math, Less Familiar
- Python: Mathematical Order of Operations
- Python: Introducing PEP 8
- Python: Text Concatenation
- Python: if Statements and Comparison Operators
- Python: else and elif statements
- Python: Testing Multiple Conditions
- Python: Testing Sets of Conditions
- Python: Nested if Statements
- Python: Lists
- Python: Adding To and Changing Lists
- Python: Lists: Take a Slice, Delete Elements, Popping Elements
- Python: Tuples
- Python: for Loops
- Python: Nested for Loops
- Python: Capturing and Formatting User Input
- Python: Dictionaries
- Python: Functions
- Python: While Loops
- Python: Data Files
- Python: Using Pexpect
- Python : Using Pexpect : ftpTestOffload.sh
- Python : Using Pexpect: ftpTest.py
- Python: DCL Conversion to Python
Go to Chapter 13 of A Smarter Way.
Now we’re into multiple nested conditions: if it’s 6:00 AM, and if you’re near a coffee shop, and if you have $5, it would be nice to get a latte.
if time <= 6:00AM: if coffee_shop_miles_distance < 1: if dollars_on_hand >= 5: print("Get a cup of coffee!") elif dollars_on_hand < 5: print("No coffee for you.") else: print("It's too late for coffee.")
All that’s necessary is to indent consistently. Each sub-block should get its own extra indentation. You can have elif and else at any level, with the usual functionality.
- Continue editing examples.py.
- Create an example code block that uses two layers of if statements, and also uses else and elif at least once.