Summary
I recorded this session to solidify my grasp of while‑loop mechanics and to guide the class through a practical coding challenge. I began by reviewing how a while loop repeats while its condition remains true and stops once the condition becomes false. I demonstrated the typical use of incrementing (counter += 1) and decrementing (counter -= 1) counters to ensure the loop eventually exits, and warned against using != in loop conditions because it can create infinite loops; instead I recommended broader comparisons such as <, >, <=, or >=. I introduced sentinel (boolean flag) variables—e.g., spot_found—to allow early termination of a loop, and showed the idiomatic Python form "while not spot_found" rather than "while spot_found == False". I explained how Jupyter signals a hanging loop with a * star and how to stop it via Kernel → Interrupt. To prevent infinite loops, I emphasized designing loop conditions that can become false, using counters, maximum attempt limits, or time constraints. I also covered the break statement for immediate exit and continue for skipping the rest of the current iteration.
After the theory, I allocated the remaining class time: individual work until the 9:50 mark, followed by a five‑minute collaborative session. Together we solved the shuttle‑wait problem by enforcing that the shuttle's wait time must be less than maxFullShuttles, and we modeled a 70% boarding probability with the expression random.random() < 0.7. I fielded a brief Q&A, offered final remarks, and encouraged participants to take a break. The next steps are to practice writing while loops with proper exit conditions, experiment with sentinel flags and break/continue, and apply the shuttle‑wait logic in their own simulations.