Question
In Python 3 Pascals triangle rules: 1. To generate the triangle, you start from the first row, which is always 1, and the second row
In Python 3
Pascals triangle rules: 1. To generate the triangle, you start from the first row, which is always 1, and the second row which is always 1 1.
2. After the first two rows, each row at level h is generated from the values at row h-1. Note that the leftmost number and the rightmost number in any row are always 1. Note that, in row h, there are h numbers.
Part 1 (A) Write a function named make_new_row that takes one argument old_row and generates the next row of Pascals triangle (starting with old_row = [1,1]).
def make_new_row(old_row): """Requires: -- list old_row that begins and ends with a 1 and has zero or more integers in between (has to have at least [1,1]) Returns: -- list beginning and ending with a 1 and each interior (non 1) integer is the sum of the corresponding old_row elements For example if old_row = [ 1,4,6,4,1], then new_row = [1,5,10,10,5,1], i.e. 5=1+4, 10=4+6, 10=6+4, 5=4+1 """
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started