Go to Chapter 12 of A Smarter Way.
What do you do if a test needs to meet two conditions at once? (Is this person both a Person and a Friend?)
This is where the keywords and and or come into play.
if student_count > 10 and chairs_count <= 10: print("Somebody's going to be standing.")
You can use more than one and orĀ or in the test:
if (doughnuts == 12 or crullers == 12)and coworkers_count <= 12: print("Everybody gets a goodie.")
Use parens to establish order of operations.
Exercises
See http://www.asmarterwaytolearn.com/python/12.html
- Continue editing examples.py.
- Create one example of a single and test, and one example of a single or test.
- Create one example of a test that involves more than one and or or.