1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Pascal's Triangle with a List

Discussão em 'Python' iniciado por Stack, Setembro 16, 2025.

  1. Stack

    Stack Membro Participativo

    My assignment is make pascals triangle using a list. I will receive the users input which is the height of the triangle and go from there. I have a psuedo code, but I just don't know how to implement the last "Else" part where it says to find the value of "A in the triangle one row up, and once column back" and "B: in the triangle one row up, and no columns back." This is the pseudo code: https://i.sstatic.net/aFwkT.jpg.

    Thanks!

    Code:

    def pascalsTriangle():
    height = int(input("Enter height of triangle:"))
    t_List = []
    for R in t_List(0,height+1):
    n_List = []
    if R == 0:
    n_List = [1]
    elif R == 1:
    n_List == [1,1]
    else:
    for C in R:
    if C == 0:
    n_List.append(1)
    elif C == R:
    n_List.append(1)
    else:
    A = t_List()

    Continue reading...

Compartilhe esta Página