四角形を再帰的に描画するのに問題があります。私の質問は、再帰的に呼び出すときに私のdraw_squares関数に渡されるべき長さです。元の正方形内に正しく収まるように思えます。添付された出力の例を見つける。 Output examplePythonで再帰的に四角形を描画する
draw_squares(side_size, depth):
turtle.forward(side_size)
turtle.left(90)
turtle.forward(side_size)
turtle.left(90)
turtle.forward(side_size)
turtle.left(90)
turtle.forward(side_size)
turtle.left(90)
if depth > 1:
turtle.penup()
turtle.left(90)
turtle.forward(side_size * 1/2)
turtle.right(90)
turtle.pendown()
else:
pass
#Draw diagonal squares within original square
def draw_squares2(side_size, depth):
if depth > 1 and depth % 2 == 0:
turtle.right(45)
draw_squares(side_size * 1/3, depth - 1)
ジオメトリについて[基本](http://mathworld.wolfram.com/PythagorassConstant.html)[knowledge](https://en.wikipedia.org/wiki/Square#Other_facts)が役立つかもしれません。 – mkrieger1
[この機能](https://docs.python.org/2/library/math.html#math.sqrt)を使用する必要があります。 – mkrieger1