CHAPTER 3

CONTROL STRUCTURES

CHAPTER OUTLINE

3.1 if Conditional Statement

3.2 Iteration (for and while Statements)

The functions that we have developed so far had the property that each instruction in a function was executed exactly once. Further, the instructions in these functions were executed in the order in which they appeared in the functions. Such functions are called straight line functions. However, real life problems would usually require non-sequential and repetitive execution of instructions. Python provides various control structures for this purpose. In this chapter, we will study the following control structures with suitable examples: if, for, and while.

 

control structures are used for non-sequential and repetitive execution ...

Get Python Programming: A modular approach 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.