#100DaysOfWeb in Python Transcripts
Chapter: Appendix: Python language concepts
Lecture: Concept: Complex conditionals

Login or purchase this course to watch this video and the rest of the course contents.
0:02 Sometimes within a control structure like if or while loops, things like that, we need to have complex tests
0:08 tests against more than one variable and negations, things like that. So, here is a pretty comprehensive example of testing for both multiple values
0:16 as well as taking over the precedence by using parenthesis and negation using not. many languages use symbols for this combination,
0:24 like the C-based languages use double ampersand for and, and exclamation mark for not, those kinds of things.
0:31 Python is more verbose and uses the English words. So here we are going to test for two conditions that both have to be True,
0:38 it's not the case that x is truthy so x has to be falsie, from the previous discussions,
0:44 so an empty sequence, None, zero, are False, something like that,
0:48 and the combination of one of two things- z is not equal to two or y itself is falsie. So, using this as an example,
0:56 you should be able to come up with pretty comprehensive conditional statements.
1:00 Now, one final note is Python is a short circuiting conditional evaluation language,
1:05 for example, if x was True, the stuff to the right and the end would not be evaluated.
1:12 You might wonder why that matters, a lot of times it doesn't, in this case, nothing really would happen.
1:16 Sometimes you want to work with like sub values of an object, so you might test that x is not None,
1:23 so you would say "if x and x.is_registered" or something like that. Whereas if you just said x.is_registered, x was None,
1:30 your app of course would crash.

Talk Python's Mastodon Michael Kennedy's Mastodon