2/19/25, 4:05 PM 352_whileloop - Colab
count=0
while(count<3):
count=count+1
print("hello")
hello
hello
hello
Start coding or generate with AI.
i=1
while(i>=0):
i=i+2
print(i)
Show hidden output
#print numbers from 1 to 10
i=1
while i<=10:
print(i)
i+=1
1
2
3
4
5
6
7
8
9
10
#print numbers from 10 to 1
i=10
while i>=1:
print(i)
i-=1
10
9
8
7
6
5
4
3
2
1
#Sum of First n Natural Numbers
n=int(input("Enter a number"))
sum=0
i=1
while i<=n:
sum+=i
i+=1
print(f"The sum of first {n}natural numbers is {sum}")
Enter a number10
The sum of first 10natural numbers is 55
#print even numbers from 1 to 20
i=0
while i<=20:
print(i)
i+=2
0
2
https://colab.research.google.com/drive/1mA9c3Jx9ktOTWNg2N0c6861kjxVZfko7 1/2
2/19/25, 4:05 PM 352_whileloop - Colab
4
6
8
10
12
14
16
18
20
https://colab.research.google.com/drive/1mA9c3Jx9ktOTWNg2N0c6861kjxVZfko7 2/2