top of page
Subham Das

If same type task is repeated by a structure till the condition is true, then it is called repetitive structure or loop.

In Python two types of loop is available :-

1. while loop

2. for loop


While loop


while loop is known as entry control loop, because, the condition of the loop. If the condition is true the loop will continue else the loop will be skipped. The while in python is started with the keyword 'while'.


For while loop a counter variable is required and which is set by suitable value according to the problem. The value of the counter variable will be incremented or decremented as per the programming logic after each and every iteration in the while loop.

Syntax of while loop:

while <condition> :

statement 1

statement 2

.

.

.

statement n

<update counter variable>


For loop


A for-loop has two parts: a header specifying the iteration, and a body which is executed once per iteration. The header often declares an explicit loop counter or loop variable, which allows the body to know which iteration is being executed. For-loops are typically used when the number of iterations is known before entering the loop. For-loops can be thought of as short hands for while-loops which increment and test a loop variable. In computer science, a for-loop (or simply for loop) is a control flow statement for specifying iteration, which allows code to be executed repeatedly.

Syntax of for loop:

for <variable> in range (start,end,interval) :

statement 1

statement 2

.

.

.

statement n

677 views0 comments
Subham Das

List in Python is a class type and its object consists of collection of elements or items of different type in an ordered sequence. It is immutable in nature.

Lists are just like the arrays, declared in other languages. Lists need not be homogeneous always which makes it a most powerful tool in Python. A single list may contain Data Types like Integers, Strings, as well as Objects. Lists are also very useful for implementing stacks and queues. Lists are mutable, and hence, they can be altered even after their creation.


In Python, list is a type of container in Data Structures, which is used to store multiple data at the same time. Unlike Sets, the list in Python are ordered and have a definite count. The elements in a list are indexed according to a definite sequence and the indexing of a list is done with 0 being the first index. Each element in the list has its definite place in the list, which allows duplicating of elements in the list, with each element having its own distinct place and credibility.






77 views0 comments
logo12.PNG
bottom of page