Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
17 views2 pages

Loop

Uploaded by

sudhir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

Loop

Uploaded by

sudhir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

In [ ]:

Loop :
To perform perticular task repetadly.

types :
for
while

control statements:
continue
break
pass

control statements(continue and break) use with Loops only


with simple if_else statement we cant use continue and break
pass we can use with simple if else statement
if if_else statement is inside loop then we can use continue and break
inside if_else statement

In [3]:

print("Good Evening")
print("Good Evening")
print("Good Evening")
print("Good Evening")
print("Good Evening")
print("Good Evening")
print("Good Evening")
print("Good Evening")
print("Good Evening")
print("Good Evening")
print("Good Evening")
print("Good Evening")
print("Good Evening")
print("Good Evening")

Good Evening
Good Evening
Good Evening
Good Evening
Good Evening
Good Evening
Good Evening
Good Evening
Good Evening
Good Evening
Good Evening
Good Evening
Good Evening
Good Evening

for loop
In [ ]:
if we want to execute some action for every element present in some
sequence (string, list, tuple,set,dict,range()) then we use for loop

syntax:
for iterative_variable in sequence:
# body of for loop
statements

In [5]:
str1 = "Data Science"
str1 = "Data Science"
print(str1[0])
print(str1[1])

D
a

In [6]:
str1 = "Data Science"

for yogesh in str1:


print(yogesh)

D
a
t
a

S
c
i
e
n
c
e

In [8]:
str1 = "Data Science"

for yogesh in str1:


print(yogesh,end=" ")

D a t a S c i e n c e

In [9]:
str1 = "Data Science"

for yogesh in str1:


print(yogesh,end="*")

D*a*t*a* *S*c*i*e*n*c*e*

In [ ]:

You might also like