5FIGURING OUT WHAT’S TRUE AND FALSE WITH BOOLEANS

image

You ask yes-or-no questions all the time: Is it raining? Is my hair too long? Once you know whether the answer is yes or no, you can decide what to do next: bring an umbrella, or not; trim your hair, or not. In all these situations, what you do depends on whether the answer to the question is yes or no. Deciding what to do based on the answer to a question is also important in programming. In this chapter, you’ll learn how to ask questions in Python.

In programming, the questions you ask are usually about comparing values. Is one value equal to another? Is a value bigger or smaller than another? ...

Get Learn to Program with Minecraft now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.