Challenge 2: Pascal's Triangle
Given a number return a list containing the values of the Pascal's Triangle of that size.
We'll cover the following
Problem Statement
Implement a function that takes a number testVariable
and returns that row of the Pascal’s triangle.
What is Pascal’s Triangle?
Pascal’s triangle is a triangular array of the binomial coefficients.
The entry in the row and column of Pascal’s triangle is denoted
For example, the unique nonzero entry in the topmost row is
With this notation, any element can be written as:
By Hersfold on Wikipedia
Input
A variable testVariable
that contains the number of the row that you have to return of the Pascal Triangle.
Output
A list containing the values of the specific row of Pascal Triangle
Sample Input
5
Sample Output
[1, 5, 10, 10, 5, 1]
Try it Yourself
Try to attempt this challenge by yourself before moving on to the solution. Good luck!
def printPascal(testVariable) :# Write your code herereturn None
Let’s have a look at the solution review of this problem.