Blog

Loop Statement in python in hindi - Bharosewale

Posted By Naveen Singh on 22 Mar 2023

python-program
python-me-loop-statement-kya-hote-hai-in-hindi

 

Python में loop statement क्या होते है?(What are loop statement in python?)

Loop statement in python in hindi

Loop statement को हम iteration भी कहते है, जिसकी सहायता से हम किसी एक code को कई बार repeat कर सकते हैं, जिस कारण से हमे उस code को बार-बार लिखना नही पड़ता है।

Python में loop basically दो प्रकार के होते हैं -

i) For loop

ii) While loop

i) For loop-: for loop का basically use हम non primitive data types( list, tuple, set) को iterate करने के लिए करते हैं। for loop का syntax बाकी programming languages से

काफी different है, for loop को use करने के लिए हम for keyword का use करते है।

Syntax-:

for variable_name in range(starting_iterater, ending_iterator+1):

   statement

जहां in एक keyword है, जिसका प्रयोग हम यह पता करने के लिए करते हैं, की की value sequence में present है कि नही।

Example-:

for i in range(1, 11):

   print(i)

Output-:

1

2

3

4

5

6

7

8

9

10

 

ii) While loop-: while loop की सहायता से हम statement के set को तब तक execute कर सकते हैं, जब तक condition true होता है।

 Syntax-:

Initialization

while(expression):

   Statement

increment/decrement

Example-:

x = 1

while x < 5:

  print(x)

  x = x+1

Output-:

1

2

3

4


 

Python में string के through looping कैसे करे?(how to looping through string in python?)

String एक तरह का character का collection होता है, और यह एक तरह का iterable object भी होता है।

Example-:

str = "Bharosewale"

for i in str:

   print(i)

Output-:

B

h

a

r

o

s

e

w

a

l

e


 

Python में break statement क्या होते हैं?( What are break statement in python?)

break statement का use करके हम किसी भी loop को break(stop) कर सकते हैं।इसका use हम तब करते है जब हम किसी loop को बीच में ही stop करना हो।

Example-:

for i in range(1,11):

  print(i)

  if i == 5:

    break

Output-:

1

2

3

4

5


 

Python में continue statement क्या होते हैं?(what are continue statement in python?)

इस statement सहायता से हम loop के current iteration को stop करके remaning iteration को continue कर सकते है।

Example-:

for i in range(1, 11):

  if i==5:

    continue

  print(i)

Output-:

1

2

3

4

6

7

8

9

10


 

Loop में range() function का प्रयोग कैसे करे?(How to use range() function in Loop?)

code के एक set के माध्यम से specified number में loop करने के लिए, हम range() function का प्रयोग करते हैं। range() function numbers sequence को return करता है, जिसकी starting 0 से और 1 का  increment होता है by default, जो कि एक specified number पर end होता है।

Example-:

for i in range(1,11):

  print(i)

जिसमे 1 include है और 11 include नही है।

 

Conclusion
 

I Hope आपको Python में looping क्या होते है? conditions python में कैसे work करता  है, और looping के types के बारे में आपको जानकारी मिली होगी। यदि आपको कोई doubt है तो comment section में comment करके पूछ सकते हैं।


 

Comments