4. Decisions and Looping

To write any but the most elementary programs, you need to be able to make decisions. Programmers have a special term for decision-making abilities: control structures. A control structure determines whether a computer will turn left or turn right, in other words, whether it will continue to operate on a set of data or exit out of a loop.

This chapter explores some of the basics of decision-making and looping within Python.

Image if and elif

Image Looping with while

Breaking from a loop

A Python guessing game, illustrating these ...

Get Python Without Fear 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.