Python while Loop In Hindi

📔 : Python 🔗

Python में While Loop ठीक वैसे ही काम करते हैं जिस तरह से C या JAVA में करते हैं। While Loop Simply Repeatedly Statements को Execute करता है , जब तक कि दी हुई Condition False न हो। जब तक Condition True है तब तक Loop Execute होगा।

While Loop को Entry Control Loop भी कहते हैं क्योंकि loop को Execute करने से पहले दी हुई condition Check होती है , condition True होने पर ही Loop में Entry होती है।

Python while Loop Syntax

while condition / expression :
#do whatever you want. or while (condition / expression) : #do whatever you want.

हालाँकि condition को आप parenthesis ( while(condition) ) में रखें या न रखें उससे फर्क नहीं पड़ता है।

Python while Loop Chart Flow

Image could not load

while Loop Chart Flow

Python while Loop Example

number = 1
table = 5 while number <= 10 : print(number, ' * ', table, ' = ', number*table ) number = number + 1

Python Nested while Loop

इसके अलावा आप Python में Nested While Loop का भी use कर सकते हैं , means While Loop के अंदर एक और While Loop.

Python Nested while Loop Example

x = 1
while x <= 10 : y = 1 print(y, end=' ') while y < x : y = y+1 print(y, end=' ') print('') x = x+1

Note : while loop use करते समय यह ध्यान रखें कि loop को terminate करने के लिए एक valid false condition होनी ही चाहिए otherwise loop endlessly run करता रहेगा जिससे पूरा program crack / hang हो सकता है।

Related Topics :

Rahul Kumar

Rahul Kumar

Hi ! My name is Rahul Kumar Rajput. I'm a back end web developer and founder of learnhindituts.com. I live in Uttar Pradesh (UP), India and I love to talk about programming as well as writing technical tutorials and tips that can help to others.

Get connected with me. :) LinkedIn Twitter Instagram Facebook

b2eprogrammers