-4

タートルで平行線を作成し、次の 4 つのパラメーターを取る関数を作成する必要があります。

  • カメ
  • 長さ、つまり各行の長さ
  • 担当者、それは描画する線の数です
  • 分離、つまり平行線間の距離

これまでのところ、私はこれを持っています:

import turtle as t

def parallelLines(length, reps, separation):
    t.fd(length)

    t.penup()

    t.goto(0, separation)

    for i in reps:
         return i
4

4 に答える 4

0

代わりにお勧めします:

def parallel():
    turtle.forward(length)
    turtle.rt(90)
    turtle.pu()
    turtle.forward(distanceyouwantbetweenthem)
    turtle.rt(90)
    turtle.forward(length)
于 2013-10-03T21:29:28.180 に答える
0

あなたはすでにあなた自身の質問に答えています:

最初の線 X の長さを描き、最初の線 Y の長さの最初から下に移動し、必要な数の担当者になるまで繰り返します

これをコードに変換すると、次のようになります。

goto start position
for _ in reps:
    pen down
    move length to the right
    pen up
    move length to the left
    move separation to the bottom

これで、turtle-API への正しい呼び出しを入力する必要があるだけです。

于 2013-09-30T18:01:02.200 に答える