day38 --------------------------------------------------------------- 实例061:杨辉三角 题目 打印出杨辉三角形前十行. 分析:查了一下,杨辉三角规律,每行多一个数,每行的值等于上一行相邻的值相加,其中边角值可以看为0,即一直为1,所以可以用列表套列表来做 代码如下: for i in range(1,10): for k in range(10-i): print(" ", end="") p…
RT Show me the Code def triangles(): b = [1] while(True): yield b b = [1] + [b[i] + b[i+1] for i in range(len(b)-1)] + [1] n = 0 for idx in triangles(): print(idx) n = n + 1 if n == 10: break…