-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex33.py
More file actions
48 lines (37 loc) · 1.06 KB
/
ex33.py
File metadata and controls
48 lines (37 loc) · 1.06 KB
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
38
39
40
41
42
43
44
45
46
47
48
i = 0
numbers = []
progression = []
matrix = []
# Program using while loop
while i < 6:
print "At the top i is %d" % i
numbers.append(i)
i = i + 1
print "Numbers now: ", numbers
print "At the bottom i is %d" % i
print "The numbers: "
for num in numbers:
print num
# Program using while loop embedded into a function
def iteration(j, k, l):
while j < k:
print "At the top j is %d" % j
progression.append(j)
j = j+l
print "Numbers now: ", progression
print "At the bottom j is %d" % j
j = int(raw_input("Please enter starting value:"))
k = int(raw_input("Please enter max limiting value:"))
l = int(raw_input("Please enter value of incrementor:"))
iteration(j, k, l)
print "The numbers: "
for num in progression:
print num
# Program using for loop embedded into a function
def generator():
for n in range(0, 6):
print "Adding %d to list." % n
matrix.append(n)
for m in matrix:
print "Number element in list is : %d" % m
generator()