“Algebraische Pyramid -Python” Code-Antworten

Algebraische Pyramid -Python

def print_pyramid(pyramid):
    lines = []
    for layer in pyramid:
        line = ""
        for brick in layer:
            line += str(brick)
            line += " "
        lines.append(line)
    pyramid_len = max([len(layer) for layer in lines])
    txt = ""
    for line in lines:
        diff = (pyramid_len - len(line)) / 2
        txt += " " * int(diff + 0.5)
        txt += line
        txt += " " * int(diff - 0.5)
        txt += "\n"
    print(txt)
Eager Eel

Algebraische Pyramid -Python


def calcul_pyramid(base):
    pyramid = [base]
    for i in range(len(base) - 1):
        actual_layer = []
        last_layer = pyramid[i]
        for j in range(len(last_layer) - 1):
            actual_layer.append(last_layer[j] + last_layer[j + 1])
        pyramid.append(actual_layer)
    return pyramid

Smiling Swan

Ähnliche Antworten wie “Algebraische Pyramid -Python”

Fragen ähnlich wie “Algebraische Pyramid -Python”

Weitere verwandte Antworten zu “Algebraische Pyramid -Python” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen