What are conditional statements?
Learn about conditional statements in python. What's the syntax and how do they help in creating programs?
Every computer language I have ever used has had at least one conditional statement. Most of the time that statement is the if/elif/else structure. This is what Python has. Other languages also include the case/switch statement which I personally enjoy, however Python does not include it. You can make your own if you really want to, but this book is focused on learning Python fundamentals, so we’re going to be only focusing on what’s included with Python in this chapter.
The conditional statement checks to see if a statement is True or False. That’s really all it does. However we will also be looking at the following Boolean operations: and, or, and not. These operations can change the behavior of the conditional in simple and complex ways, depending on your project.
Let’s see how if statements
work:
Get hands-on with 1400+ tech skills courses.