bing
Flat 10% & upto 50% off + 10% Cashback + Free additional Courses. Hurry up
×
UPTO
50%
OFF!
Intellipaat
Intellipaat
  • Live Instructor-led Classes
  • Expert Education
  • 24*7 Support
  • Flexible Schedule

 

While Loop

In this body is executed until condition is true. Once the condition becomes false then control comes out the loop.

Syntax 

while condition:

Body of while loop

while loop

 

e.g.

i = 10

while i>5:

print i

i=i-1

Output 

10

9

8

7

6

 

For Loop

For loop executes the sequence of code according to the specified times and conditions.

Syntax

for variable in sequence:

Body of for loop

for loop

 

e.g.

i=1

for i in range(1,8):

print 2*i

Output 

2

4

6

8

10

12

14

 

Nested Loop 

Loop defined within another loop is known as nested loops.

Syntax 

for condition1:

for condition2:

Body of for loop

This blog will help you get a better understanding of Automate Your Coding with Python!

Previous Next

Download Interview Questions asked by top MNCs in 2018?

Learn SQL in 16 hrs from experts



"0 Responses on Python Loops"

100% Secure Payments. All major credit & debit cards accepted Or Pay by Paypal.
top

Sales Offer

Sign Up or Login to view the Free Python Loops.