6MAKING MINI-GAMES WITH IF STATEMENTS
In Chapter 5, you learned how to ask questions in Python. You used comparison operators (like ==, !=, >, <, and so on) and logical operators (and, or, not) to find out whether a condition or set of conditions evaluated to True or False. In this chapter, you’ll use the answers to these questions—the results of the conditions you test—to decide what code to run.
You make decisions based on conditions every day. Is it nighttime? If so, you wear your diamond armor and bring a sword to fight off monsters. If not, you might leave all your gear in your secret base. Are you hungry? If that’s true, you eat some bread ...
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.