我一直在尝试创建一个显示乘法表的程序,就像这样。 [![在此处输入图像说明][1]][1]
我在编码方面遇到了很多问题。当我像现在这样运行程序时,它看起来是这样的: [![在此处输入图像说明][2]][2]
下面是我的代码:
import turtle
turtle.hideturtle()
turtle.penup()
turtle.write((" Multiplication Table"), font =("Arial",20,"bold"))
for dash in range(-13, 250, 5):
turtle.goto(dash, -40)
turtle.write((" - "), font =("Arial", 10, "bold"))
j = 1
for topFactor in range( 15, 240, 28):
turtle.goto( topFactor, -30)
turtle.write( str( j )+ " |",font=("Arial",10,"bold"))
j +=1
l = 1
for rightFactor in range( 50, 240, 22):
turtle.goto( -10, -rightFactor)
turtle.write( str( l )+ " |",font=("Arial",10,"bold"))
l +=1
for topFactor in range(15, 240, 28):
turtle.goto( topFactor, -50)
turtle.write( str(l * j), font=("Arial",10,"bold"))
turtle.done()
我会很感激你的帮助。在
这一行阻止数字填充整个表:
它应该是:
^{pr2}$另外,您对
l * j
的计算是关闭的,因为j
在代码中此时不会随列而递增。这里有一个潜在的返工:相关问题 更多 >
编程相关推荐