4 Conditional Statements
The programs you have written so far execute line by line, beginning at the top of the code and ending at the bottom. You can visualize this flow as a series of steps that execute in a linear fashion, which means that the program can run in only one way. In this chapter, you’ll explore how to write divergent paths for Python to follow, depending on whether certain conditions are met. This is useful because you can execute different actions in your program depending on the scenario—think of the way a video game directs you to different levels or screens contingent on your performance.
To evaluate a condition, you’ll ...
Get Learn Python Visually 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.