In: Computer Science
E.g., given an array-backed list lst containing the elements [0, 1, 2, 3, 4, ..., 98, 99], the following code:
for x in lst.poly_iter(2, 3, 4): print(x)
will produce the output:
4 9 18 31 48 69 94
Programming rules:
class ArrayList:
def __init__(self):
self.data = []
def poly_iter(self, a, b, c):
# YOUR CODE HERE
class ArrayList:
#constructor
def __init__(self):
self.data = []
#Creating List
def poly_iter(self, a, b, c):
lst = []
for i in range(0, 100):
lst.append(i)
res = 0
i = 0
while True:
res = (a*i*i)+(b*i)+c
if res < lst[-1]:
self.data.append(res)
else:
break
i += 1
return iter(self.data)
lst = ArrayList()
for x in lst.poly_iter(2, 3, 4):
print(x)
******************************************************************************************
PLEASE LIKE IT RAISE YOUR THUMBS UP
IF YOU ARE HAVING ANY DOUBT FEEL FREE TO ASK IN COMMENT
SECTION
******************************************************************************************