Python Programming – Control Structures

Generally, a program is executed in a sequence normally from top to bottom. The statements get executed one after the other as the interpreter transfers the control from the current statement to the next statement as soon as the execution of the current statement gets over. However, in some situations, the sequential flow does not work. The control needs to move to some other location in the program depending upon certain conditions or there may be a requirement to execute a set of statements repetitively. Therefore, this chapter intends to emphasize control structures that are used to alter the order of execution of a program. In this chapter, we will learn three types of control structures decision making, looping, and controlling.

Summary

In this chapter, we have learned all the control structures provided by Python. language. The decision-making statement if, if-else, elif, nested if are elaborated thoroughly. The most likely used looping constructs while and for are discussed with appropriate programming examples of each. The new features of Python while loop with else, for loop with else, and range() function are explained with their instances. Other control statements such as break, continue, and pass is also discussed. The flow diagrams of all the control structures are also given.

Python Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *