Python 3 tutorial for beginners in Hindi-Chapter 17(While loop)

Updated: Nov 10, 2020

While Loop in Python

While loop एक known range की दोहराव प्रक्रिया है।

Syntax

while condition:
   statement 1
   statement 2
other statements

उपरोक्त syntax में यदि condition सही है तो लूप execute करेगा , अन्यथा अन्य स्टेटमेंट execute होंगे।

Write a program to display 1 to 10 numbers using while loop


no =1
while no! = 11:
   print(no,end=" ")
   no += 1

Output:

1 2 3 4 5 6 7 8 9 10


Write to print the reverse of a number(no)

reverse = 0
while no!=0
   r = no%10
   n = no//10
   reverse =(reverse * 10)+r
print("Reverse of the number is:",reverse)