Python,带有少量打印的数字三角形,主要是循环和if



我甚至没有接近,这是它应该显示的方式:

<>前100200 202300 304 308400 406 412 418.........900 916 932…1028这是我一直在尝试的:

for i in range(100,1000,100):

for j in range(100,1000,100):


print(i,"  ",end="")


print("")





x=0
for i in range(1,10,1):
x+=2
for j in range(1,10,1):
x+=2

print(x,"  ",end="")
x=0  


print("")




for i in range (10):
for j in range(10):

x=(j*2+(i*2*j))

print(x,"  ",end="")


print("")  





for i in range(100,1000,100):

for j in range(100,1000,100):


print(i,"  ",end="")


print("")

try this:

for index, i in enumerate(range(100, 1000, 100)):
num = i
for j in range(index + 1):
print(num, end=" ")
num += index * 2
print()

输出:

100 
200 202 
300 304 308 
400 406 412 418 
500 508 516 524 532 
600 610 620 630 640 650 
700 712 724 736 748 760 772 
800 814 828 842 856 870 884 898 
900 916 932 948 964 980 996 1012 1028
``
for i in range(100,100+1,1):
print(i,"  ",end="")
print("")

for i in range(200,202+1,2):
print(i,"  ",end="")

print("")

for i in range(300,308+1,4):
print(i,"  ",end="")

print("")

for i in range(400,418+1,6):
print(i,"  ",end="")

print("")


for i in range(500,532+1,8):
print(i,"  ",end="")

print("")


for i in range(600,650+1,10):
print(i,"  ",end="")



print("")



for i in range(700,772+1,12):
print(i,"  ",end="")



print("")




for i in range(800,898+1,14):
print(i,"  ",end="")



print("")







for i in range(900,1028+1,16):
print(i,"  ",end="")

print("")


相关内容

  • 没有找到相关文章

最新更新