While loop

0
1292

While loop सभी programming language में use होता है while loop में हम if की ही तरह condition लगाते है but यहाँ पर difference यह है कि if वाली condition जब true होती है तो if वाला block एक बार ही execute होता है लेकिन while loop में जब तक condition true रहेगी जब तक वो execute करता रहेगा जैसे ही condition false हो जायेगी ये रूक जायेगा।

          Synatx:
                 while (expression):
	                statement(s)
          Example:
                  a = 1
                    while (a < 6) :
                       print("Value of a is ", a)
                    a = a + 1
           Output:
                  Value of a is 1
                  Value of a is 2
                  Value of a is 3
                  Value of a is 4
                  Value of a is 5

while Loop with else Statement

while Loop के साथ else का use ये है जब condition true होती है तब while loop का statement execute होता है और condition false होती है तब control pass होके else पर जाकर else वाले statement को execute करता है।

       Example:
               a =1 
                while(a < 6):
                 print("Value of a is ", a);
                a = a + 1
               else:
                 print("Out of Loop");
       Output:
               Value of a is 1
               Value of a is 2
               Value of a is 3
               Value of a is 4
               Value of a is 5

While loop को पढ़ने के बाद अन्य प्रकार के looping statements नीचे दिये हुये हैं।

इन्हें भी देखें।

Python Programs के लिये यहाँ click करें।

 

 

While loop while loop in hindi while loop in python while loop in python in hindi while loop in python estudyhelper while loop in python estudyhelper.xyz for loop in python for loop in python in hindinested loop in pythonnested loop in python in hindi while loop in python syntax while loop in python syntax in hindi while loop in python with and conditionc reate a while loop in python create a while loop in python in hindiwhile loop python definition while loop python definition in hindi while loop definition in python in hindi while loop definition in python while loop with example in python python while loop with example in hindi python while loop with example

LEAVE A REPLY

Please enter your comment!
Please enter your name here