About Lesson
What is while loop ?
A while loop in Python is a control structure that repeatedly executes a block of code as long as a specified condition is true. It is useful for situations where the number of iterations is not known in advance.
Python
#Syntax
while condition:
# Code block to execute
Example :
Python
i = 0
while i < 5:
print(i)
i += 1 # Increment count
#Output
0
1
2
3
4
num=int(input("Enter the Number:"))
i=1
x=1
while i<=10:
x=num*i
print("",i,".""",num,"x""",i,"=""",x)
i=i+1
#Output =
Enter the Number:5
1 . 5 x 1 = 5
2 . 5 x 2 = 10
3 . 5 x 3 = 15
4 . 5 x 4 = 20
5 . 5 x 5 = 25
7 . 5 x 7 = 35
8 . 5 x 8 = 40
9 . 5 x 9 = 45
10 . 5 x 10 = 50