-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path08_loops.py
37 lines (33 loc) · 851 Bytes
/
08_loops.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
print("----------for condition--------")
for i in range(5):
print(i)
print("--------------------------------")
words = ['cat', 'window', 'defenestrate']
for w in words:
print(w, len(w))
print("------while condition---------")
#1.initilization
#2.condition
#3.itration/incrament-decrement
total =4
i=1
while i>total:
print("helo")
i = i+1
#1.
for n in range(2, 10):
for x in range(2, n):
if n % x == 0:
print(n, 'equals', x, '*', n//x)
break
else:
# loop fell through without finding a factor
print(n, 'is a prime number')
for num in range(2, 10):
if num % 2 == 0:
print("Found an even number:",num)
continue
print("Found an odd number:",num)
#starting point->ending point->increment
for i in range(0,16,4):
print("HELO",i)