Can boolean expressions be combined?



Within the context of this exercise, can boolean expressions be combined into a longer expression?


Yes, we can combine multiple boolean expressions together to form a longer expression. For example, if we had the expressions,

Penguins are birds.


Penguins cannot fly.

we can combine them into a longer expression, either using an or or and operator which will be covered in the later exercises, resulting in

Penguins are birds AND Penguins cannot fly.

If we evaluated this for say an if statement, then this would become

True and True = True

and we might print out “Penguins are flightless birds” inside the if statement body.

This general idea is what we apply to boolean expressions in Python to combine multiple expressions together.


Armchair critic:

The logic that emerges here suggests that birds that cannot fly are penguins. At least slightly by my fuzzy logic.

Turkeys are birds that cannot fly, thank heaven for that come the autumn tradition. Can you imagine if ostriches could fly the havoc they would reak on a city? Penguins are pretty much confined to a locale. We would need to add that to our data parameters.