Okey,实际上我真的不知道如何在python中打印金字塔,更糟糕的是,我需要得到这个: Pyramid of n numbers
询问金字塔的长度
这是代码。
n = int(input("\n Enter the lenght of the triangle.. "))
for i in range(n):
for j in range(n - i):
print(" ", end = " ")
for k in range(i):
print("*", end = " ")
print()
答案 0 :(得分:1)
选项之一:
import numpy as np
a = int(input())
def pyram(a):
n = np.zeros(a)
hal = int((a+2)/2)+1
n[:(hal-1)] = range(1,hal)
n[(hal-1):] = np.array(range(1,hal-1))[::-1]
print(n)
for i in range(1,a*2,2):
pyram(i)