def generate_pascal_triangle(num_rows):
triangle = []

for row in range(num_rows):
current_row = []

for element in range(row + 1):
# If the element is the first or last in the row, set it to 1
if element == 0 or element == row:
current_row.append(1)
else:
current_row.append(triangle[row-1][element-1] + triangle[row-1][element])

triangle.append(current_row)

return triangle


triangle = generate_pascal_triangle(5)


for row in triangle:
print(row)

What is the output of the following program

Posted on by