Question: i want the solution for question 2 Hans Question 1 Copointe Vitrite an iterative Python function called generate_i(n) that generates a series or rows of

Hans Question 1 Copointe Vitrite an iterative Python function called generate_i(n) that generates a series or rows of numbers stored as sublists according to the following rules Start by returning (1) for n-1 Continue by returning (1, 1) for nu2 Each remaining row of values will thus continue to have one more value than the previous row. For example, the fifth row will have five values, while the fourth row has four. The values on both ends of the current row will always be 1 for n > 1 Starting with the second row, each internal cell will be the Sum of the two cells diagonally right above that cell . Hence, n such rows should be generated by generate_1(n) Below is a pictonal descrption of the values that should be generated with the call generate_1( 6 ) For exampletake the row before last from the bottom Both ends have 1. as required. The first leftmost value after 1 is 4 , because above it are cells 1 and 3 whose sum is 4. The middle clement of the last row to be generated for nu6 is 6, because above it are two 35. Your generate(n) function will return a list of lists, in which each sublist will store one of these rows of numbers, starting with 1 at the top. Therefore, the return value of generate_1( 6 ) should be (11), (1, 1), (1, 2, 1), (1, 3, 3, 1), (1, 4, 6, 4, 1), (1, 5, 10, 10, 5, 1]] where each row is represented by a sublist. So there are 6 sublists for nuk . As mentioned above, your generate_10 function must be iterative, that is, it must strictly use looping to do its Job. . You are not allowed to use import statements or the zip) function. If you do your grade will automatically be zero . You are not allowed to define additional functions! So you should only define generate_10) in your solution. If you define additional helper functions external or internal to generate_10 they will be automatically detected and unfortunately, your grade will be zero You will use the Jupyter Notebook Pe magic directive (file ... ) to store your solution as generate_i.py Therefore, do not remove this directive from the top of the following code cell, OOOOOO Question 2 cc points 55 mins ELSE: You will solve the same exact problem as in Question 1, but this time you will write a recursive Python function called generaterin) that generates a series or rows of numbers stored as sublists according to the above-mentioned rules. To help you a possible algorithm for the task is provided to you below. Intentionally though, not every detail is given in this algorithm, and the details you need to fill in are all about how you must go about implementing each of the steps mentioned in this algorithm. Algorithm Generate_R(n): IF n is 1 THEN: RETURN [[1]] w = generate rows for the previous (n - 1) rows pp = grab the last row from w rr = generate values for the current row using values in pp 85 - build/join the entire set of rows from rr and w RETURN The implemention below provides a few tines of the implementation of the above algorithm. On the other hand, you have complete freedom as to how you may wish to implement a solution, as long as that solution is recursive! The algorithm above and the code snippet below are only suggestions in the right direction. Remember that multiple solutions that satisfy the specifications are possible is no single solution . When you run the following cell, a file namd generate_r.py should be created, since a file magic directive is used at the top of the cell. You should not modify this line . Again, a function that you write may work. However, if it fails to follow the strict specifications provided to you, unfortunately, you will not get any grade for this question. So, if you do not remember additional specifications about what you are not allowed to do please refer to Question 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
