python loop 英文问题
1个回答
展开全部
from __future__ import print_function
def problem1():
for i in range(5):
print(" ".join(str(x) for x in range(10)))
print(" " * 8, 0)
print(" ".join(str(x) for x in range(10)))
def problem2():
for i in range(10):
print(" " * i, end="")
print(" ".join(str(x) for x in range(10 - i)))
problem1()
print("=======================")
problem2()
运行结果
0 1 2 3 4 5 6 7 8 9
0
0 1 2 3 4 5 6 7 8 9
0
0 1 2 3 4 5 6 7 8 9
0
0 1 2 3 4 5 6 7 8 9
0
0 1 2 3 4 5 6 7 8 9
0
0 1 2 3 4 5 6 7 8 9
=======================
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6
0 1 2 3 4 5
0 1 2 3 4
0 1 2 3
0 1 2
0 1
0
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询