From the course: Programming Foundations: Real-World Examples
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Polling for a condition - Python Tutorial
From the course: Programming Foundations: Real-World Examples
Polling for a condition
- There will be times when you need a program to detect that some event has occurred, and then react to that event by performing a certain action. To accomplish that, there are two approaches you could use: polling, or event-driven programming. With the polling method, a program is continuously checking and checking and checking and actively checking for a certain condition to occur, like a button being pressed. And when it sees that the condition has occurred, it'll then perform an appropriate action. My house is ready for my friends, so now I'm just waiting for the pizza delivery guy to get here. When the pizza man arrives, I'll need to perform the appropriate action by opening the door, and getting the pizza. So, how will I know when the pizza man is on the front porch to get my pizza? Well, I could try the polling method, and to do that, I'll have to get up off my bed, then I go down the stairs, (door opens) I check to see if he's here. Not yet. (door closes) So then I head back…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.