A Boolean value represents one of two truth values: True or False. Comparisons such as char == 'o' return a Boolean value, while assignment with = changes a variable. section 2.1.10
Use Boolean values to test conditions and combine results:
- Compare values with ==; use = only for assignment. section 2.1.10
- Combine conditions with and and or according to Boolean algebra. section 2.1.10 section 21.0
- Use membership tests such as word[0].lower() in 'aeiou' to produce a Boolean result. section 2.1.10
Testing a vowel
>>> word = 'OCTOPUS' >>> word[0].lower() in 'aeiou' True The expression returns True because the lowercased first character, 'o', occurs in 'aeiou'. section 2.1.10
>>> char == 'a' or char == 'e' or char == 'i' or char == 'o' or char == 'u' True
Inspect how several equality comparisons combine with or to return one Boolean result. section 2.1.10










