ungleich-learning-circle/youngjin.han/python-the-hard-way/ex33.py

45 lines
986 B
Python
Raw Normal View History

from sys import argv
script, a_iteration, a_increment = argv
#i = 0
g_numbers = []
def while_loop(p_iteration, p_increment):
l_i = 0
l_numbers = []
while l_i < p_iteration:
print(f"At the top i is {l_i}")
l_numbers.append(l_i)
l_i += p_increment
print("Numbers now: ", l_numbers)
print(f"At the bottom i is {l_i}")
return l_numbers
def for_loop(p_iteration, p_increment):
l_numbers = []
for l_i in range(0, p_iteration, p_increment):
print(f"At the top i is {l_i}")
l_numbers.append(l_i)
print("Numbers now: ", l_numbers)
print(f"At the bottom i is {l_i}")
return l_numbers
g_numbers = while_loop(int(a_iteration), int(a_increment))
print("The numbers: ")
for num in g_numbers:
print(num)
print("=====================================")
g_numbers = for_loop(int(a_iteration), int(a_increment))
print("The numbers: ")
for num in g_numbers:
print(num)