1. infinite loop
while 1 == 1: print('ok')
The result is been circulating
2. cycle
count = 0 while count < 10: print(count) count = count +1 print(error)
3. Exercises
~ Output while loop 1234568910
. 1 = COUNT the while COUNT <= 10: # or COUNT <. 11 IF COUNT ==. 7 : Print () # may be added to pass, nothing is performed the else : Print (COUNT) COUNT = COUNT +. 1
Results of the:
1
2
3
4
5
6
8
9
10
Process finished with exit code 0
~ Find all the numbers from 1 to 100 and
a = 1 b = 0 while a < 101: b = b + a a = a + 1 print(b)
Output:
5050
Process finished with exit code 0
All odd request 1-100 ~
n = 1 while n < 101: js = n % 2 if js == 0: print( ) else: print(n) n = n + 1
Output:
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99
All even-numbered 1-100 ~ seek
a = 1 while a < 101: b = a % 2 if b == 0: print(a) else: pass a = a + 1
Output:
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
62
64
66
68
70
72
74
76
78
80
82
84
86
88
90
92
94
96
98
100
Process finished with exit code 0