Real decisions often depend on more than one fact, so Python lets you combine conditions with the logical operators and, or and not. a and b is true only when both are true. a or b is true when at least one is true. not a flips a value. For example, if age >= 18 and has_ticket: requires both, while if day == "Sat" or day == "Sun": accepts either. These are keywords, written in lower case; the symbols &&, || and ! from other languages are not valid Python.
Keep reading for free
Create a free StudyToCert account to read the rest of this lesson: 7 more sections, 5 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.