PYTHON without Def funciton Problem Statement In Pascal's triangle, each number is the sum of the two numbers directly above it (see image). Complete a function called "pascal_next_row" which has one list parameter, previous_row. This function should use the function's input (the previous row of Pascal's triangle) to create a new list that is the next row in the triangle. The function should then return this new list (i.e., the next row of Pascal's triangle). Below your function definition, ask the user for a non-negative integer, numrows, which represents the number of rows of Pascal's triangle to create/print. Then call your function multiple times to create a list of lists that represent Pascal's triangle with numrows rows. After your list of lists is created, print each row in the final list.
PYTHON without Def funciton
Problem Statement
In Pascal's triangle, each number is the sum of the two numbers directly above it (see image). Complete a function called "pascal_next_row" which has one list parameter, previous_row. This function should use the function's input (the previous row of Pascal's triangle) to create a new list that is the next row in the triangle. The function should then return this new list (i.e., the next row of Pascal's triangle).
Below your function definition, ask the user for a non-negative integer, numrows, which represents the number of rows of Pascal's triangle to create/print. Then call your function multiple times to create a list of lists that represent Pascal's triangle with numrows rows. After your list of lists is created, print each row in the final list.
Sample Input 1
2
Sample Output 1
[1] [1, 1]
Sample Input 2
5
Sample Output 2
[1] [1, 1] [1, 2, 1] [1, 3, 3, 1] [1, 4, 6, 4, 1]
Starting code
def pascal_next_row(previous_row):
# this function should compute the next row and return it as a list
# Your function code here
numrows = int(input())
#Your code here
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images