Loops in Python

Pythoncode4you

Python Tutorial



In previous blog we learn basic concepts about python and datatypes of Python and also operators in Python. The link of the previous blog is pythoncode4you
In this blog we learn Loops in Python. There are two looping statements in Python that is two types of loops in Python are as follows:

  • For Loop
  • While Loop

1.For Loop

A for loop in Python is control flow statement that is used yo repeatedly execute a group of statements as long as the condition is satisfied. Such a type of statement is known as iterative statement. Therefore, a this for loop is also known as iterative statement.

Program:


Output:


For Loop using string


Program


Output:

2.While Loop

The while loop is control statement that is used to execute a set of statement as long as long as a condition is true. When the condition is false, the line immediately after the loop in the program is executed. While loop is under the category of indefinite iteration.


Output:

5 Comments

Previous Post Next Post