Question: Use Pascal Triangle Template on python: Print Pascal's triangle by adding code to the given template file. Print the triangle up to row 6. Please

Use Pascal Triangle Template on python:

Use Pascal Triangle Template on python: Print Pascal's triangle by adding code

Print Pascal's triangle by adding code to the given template file. Print the triangle up to row 6. Please make sure that the program can run. Thank you.

This is what it should look like.

to the given template file. Print the triangle up to row 6.

Also, this is what I have and I'm new to programming, but I keep getting an error on line 8, so if you could help me correct it and explain what had happened, or find a more reasonable solution Id appreciate it.

def pascal_triangle(n): line = [1] a = [] for i in range(n): a.append([]) a[i].append(1) for j in range(1,i): a[i].append(a[i-1][j-1]+a[i-1][j]) if(n>1): a[i].append(1) line = a[n-1] print (line) return line pascal_triangle (6)

def pascal triangle (n): line [1] # Put your code here print (line) return line pascal triangle (6)

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!