Conditional Statements & Event Handling: How Do I Control the Program Flow and Make the Program React to User Actions and Other Events?
摘要
This chapter is about how to branch within a program depending on the situation, for example, when processing user input. We will therefore look at Python’s version of the classic If-Else statement, which is used to execute alternative parts of the code depending on certain conditions, and how to make your program flow respond to events, such as user clicks on a graphical user interface.