Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

algebraic 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 += "
"
    print(txt)
Comment

algebraic 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

Comment

PREVIOUS NEXT
Code Example
Python :: rename last layer of keras model 
Python :: 0x80370102 kali linux 
Python :: python toupper 
Python :: python sum only numbers 
Python :: how to add items to a set in python 
Python :: fastest way to compute pair wise distances python 
Python :: horizontal barplot 
Python :: Does Flask support regular expressions in its URL routing 
Python :: reverse relationship in django for one to one field for usage in Django rest serializer 
Python :: interface in python 
Python :: query first 5 element in django 
Python :: input check in pygame 
Python :: filtering certain rows in python that contains a part of string 
Python :: hello world in python 3 
Python :: get dummies pandas 
Python :: how to get var value by name godot 
Python :: if statement python 
Python :: aws django bucket setting 
Python :: mistborn series 
Python :: django q example 
Python :: histogram python 
Python :: python format decimal list 
Python :: how to create a function in python 
Python :: flask run development mode 
Python :: change folder icon with python 
Python :: upload file django 
Python :: how to pre populate field flask wtforms 
Python :: What are Augmented Assignment Operators in python 
Python :: or en python 
Python :: Python NumPy stack Function Example with 2d array 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =