Question: Python 3: Pascals triangle is an infinite two-dimensional pattern of numbers whose first five lines are illustrated in Figure 10.22. The first line, line 0,

Python 3: Pascals triangle is an infinite two-dimensional pattern of numbers whose first five lines are illustrated in Figure 10.22. The first line, line 0, contains just 1. All other lines start and end with a 1 too. The other numbers in those lines are obtained using this rule: The number at position i is the sum of the numbers in position i 1 and i in the previous line. Implement recursive function pascalLine() that takes a nonnegative integer n as in- put and returns a list containing the sequence of numbers appearing in the nth line of Pascals triangle.

>>> pascalLine(0)

[1]

>>> pascalLine(2)

[1, 2, 1]

>>> pascalLine(3)

[1, 3, 3, 1]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!