- loops are used to iterate the condition
- loop are divided into two types
- for loop , while loop
while loop
- syntax
- initialization , condition , up dation
count = 1 # initialization
while count <=10 : # conditon
print("print Hello")
count = count+1
1 st program
- print number from 1 to 100
i = 1
while i == 100 :
print(i)
i = i+1
2nd program
- print numbers from 100 to 1
i = 100
while i >= 1 :
print(i)
i = i-1
3rd program
- print the multiplication table of a number n
n = int(input("enter the number : ", ))
i = 1
while i <= 10 :
print(n*i)
i = i+1
4th program
- print the element of the following list using a loop
- [1,,4,9,16,25,36,49,64,81,100]
n = [1,4,9,16,25,36,49,64,81,100]
i = 0
while i <= len(n)-1:
print(n[i])
i = i+1