[solved]-Traceback Recent Call Last File Line 1 Next File 1py Line 207 Next Raise Stop Iteration S Q39020219
Python question, please help! Its problem three parts a-e


Traceback (most recent call last): File “<pyshell#190>”, line 1, in <module> next(it) File “……/1.py”, line 207, in _next__ raise Stop Iteration StopIteration Part b). Generator Write a Python generator called rnd_gen(x0, n) that takes a positive integer seed x0 and an int n and produces the sequence of the first n pseudo-random numbers (if n 20) or an infinite sequence of numbers (if n <0). This generator is defined as a function that uses the yield keyword to output a value, as seen on the Chapter 16 lecture PDF file, on slides 60-70. This generator produces the same number sequence as the RndSeq class from part a). Here is how it can be used in a for loop to print the first 10 pseudo-random numbers with seed 1: >>> (i for i in rnd_gen(1, 10)] [22695478, 2156045615, 2867233980, 71484141, 2911408402, 2613937339, 1153135800, 420428313, 1503962414, 4187371143] >>> list(rnd_gen(1, 3)) [22695478, 2156045615, 2867233980] Add in this file a function called main() that demonstrates both the class and the generator by creating and printing lists with the first 10 prime numbers with seed 2. Take a screenshot with the output of the main() function and insert in the PDF file. Problem 3. Functional Programming Write all the code for this problem in a file named p3_Lastname_Firstname.py. a) Write a generator gen_rndtup(m) that creates an infinite sequence of tuples (a, b) where a and b are two random integers obtained using the rnd_gen(1, -1) generator from Problem 2 and 0 sasb<m. (Hint: Remember that for any positive integers m and q,0 54% m<m. If q is random, then q% mis also random.) b) Write code that uses lambda expressions, the itertools.islice function (https://docs.python.org/3/library/itertools.html#itertools.islice), and the filterfalse function to display the first 8 generated tuples (a, b) from gen_rndtup(10) (from part a) that have a + b >= 6. Example: with n==10 the output could be: (2,5), (5,5), (1,6),(7,9),… c) Write a for loop using generator expressions, the zip function to display the first 8 tuples (a, b) where a is obtained using generator rnd_gen(1, -1), b is obtained using generator rnd_gen(2, -1), and 0 Sasb s 100. The idea is to filter out tuples for which a > b. d) Write code with the gen_rnd(1, -1) generator, lambda expressions, map(), itertools.islice, and the filter functions to display the first 10 random numbers between 0 and 100 that are divisible to 13. e) Write code with generator gen_rndtup(m=10) from part a), lambda expressions, map(), the itertools.islice, functools.reduce(), and the filter functions to display the sum of first 10 generated tuples (a, b) that have sum a + b >= 5. The sum of tuples is done component-wise for each tuple element. E.g. if the sequence filtered is (1,5), (2,6), (6,6),(3,5), then the sum of these tuples that is displayed is (1+2+6+3, 1+6+6+5) = (12, 22). Run the code from parts a), e) and take one or more screenshots with the output. Include the screenshots in the PDF file. Show transcribed image text Traceback (most recent call last): File “”, line 1, in next(it) File “……/1.py”, line 207, in _next__ raise Stop Iteration StopIteration Part b). Generator Write a Python generator called rnd_gen(x0, n) that takes a positive integer seed x0 and an int n and produces the sequence of the first n pseudo-random numbers (if n 20) or an infinite sequence of numbers (if n >> (i for i in rnd_gen(1, 10)] [22695478, 2156045615, 2867233980, 71484141, 2911408402, 2613937339, 1153135800, 420428313, 1503962414, 4187371143] >>> list(rnd_gen(1, 3)) [22695478, 2156045615, 2867233980] Add in this file a function called main() that demonstrates both the class and the generator by creating and printing lists with the first 10 prime numbers with seed 2. Take a screenshot with the output of the main() function and insert in the PDF file. Problem 3. Functional Programming Write all the code for this problem in a file named p3_Lastname_Firstname.py. a) Write a generator gen_rndtup(m) that creates an infinite sequence of tuples (a, b) where a and b are two random integers obtained using the rnd_gen(1, -1) generator from Problem 2 and 0 sasb b.
d) Write code with the gen_rnd(1, -1) generator, lambda expressions, map(), itertools.islice, and the filter functions to display the first 10 random numbers between 0 and 100 that are divisible to 13. e) Write code with generator gen_rndtup(m=10) from part a), lambda expressions, map(), the itertools.islice, functools.reduce(), and the filter functions to display the sum of first 10 generated tuples (a, b) that have sum a + b >= 5. The sum of tuples is done component-wise for each tuple element. E.g. if the sequence filtered is (1,5), (2,6), (6,6),(3,5), then the sum of these tuples that is displayed is (1+2+6+3, 1+6+6+5) = (12, 22). Run the code from parts a), e) and take one or more screenshots with the output. Include the screenshots in the PDF file.
Expert Answer
Answer to Traceback (most recent call last): File “”, line 1, in next(it) File “……/1.py”, line 207, in _next__ raise Stop Iter… . . .
OR

