Looping Statements

The programming languages provide various kinds of loops that are able to repeat some particular code numerous numbers of times. The loops in python are - 

1. For Loop - The for loop is used in the case where a programmer needs to execute a part of the code until the given condition is satisfied. The for loop is also called a pre-tested loop. It is best to use for loop if the number of iterations is known in advance.

2. While Loop - The while loop is to be used in situations where the number of iterations is unknown at first. The block of statements is executed in the while loop until the condition specified in the while loop is satisfied. It is also called a pre-tested loop. In Python, the while loop executes the statement or group of statements repeatedly while the given condition is True. And when the condition becomes false, the loop ends and moves to the next statement after the loop.

3. Nested Looping statements - The Python programming language allows programmers to use one looping statement inside another looping statement.

Comments

Popular posts from this blog

Flow of Control

Conditional Statements

Strengths and Weaknesses of Python