Course Content

If you are facing any issue in playing video please use Firefox browser.

Course Content

Description

Loops Statement In Python 1

 

In this lecture we will see that, What is loop ?, Which are the types of loop ?, How to work with 'while' loop ?

 

Suppose, we have a code and when we want to execute that code for more than twice or thrice, we use 'loop'. In loop starting point and ending point matters most.

 

Python programming language provides following types of loops to handle looping requirements –

  • While loop
  • Nested while loop
  • For loop
  • Nested for loop
  • For loop with range()

 

While loop

 

This loop is used in every programming language. A while loop statement in Python programming language repeatedly execute the target statement as long as the given condition is true.

 

Syntax :

while expression:

statement(s)

 

Example :

count=0

while(count<10):

print ('Count :',count)

count+=1;

O/P :

Count : 0

Count : 1

Count : 2

Count : 3

Count : 4

Count : 5

Count : 6

Count : 7

Count : 8

Count : 9

 

Nested while loop

 

Syntax :

while expression:

statement(s)

while expression:

statement(s)

 

Example :

tables=3

while(tables<4):

print('Tables of',tables)

mul=1

while(mul<=10):

print(table,' * ',mul,' = ',table*mul)

mul+=1;

print()

table+=1;

O/P :

3 * 1 = 3

3 * 2 = 6

3 * 3 = 9

3 * 4 = 12

3 * 5 = 15

3 * 6 = 18

3 * 7 = 21

3 * 8 = 24

3 * 9 = 27

3 * 10 = 30

FAQs

Share With Friend

Have a friend to whom you would want to share this course?

Download The Apps

Code Scan or Download the app
Google Play Store
297K+ Downloads
4.5 Rating
10K+ Reviews
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere