當前位置:編程學習大全網 - 編程軟體 - python turtle畫4個同心圓方法

python turtle畫4個同心圓方法

import?turtle

#draw?first?circle

turtle.penup()

turtle.goto(0,-200)

turtle.pendown()

turtle.circle(200)

#draw?second?circle

turtle.penup()

turtle.goto(0,-150)

turtle.pendown()

turtle.circle(150)

#draw?third?circle

turtle.penup()

turtle.goto(0,-100)

turtle.pendown()

turtle.circle(100)

#draw?fourth?circle

turtle.penup()

turtle.goto(0,-50)

turtle.pendown()

turtle.circle(50)

畫筆的坐標默認在0,0,就以它為圓心。

因為turtle畫圓的時候是從圓的底部開始畫的,所以需要找到四個圓底部的坐標

比如:

第壹個半徑為200的圓,底部為(0,-200)

第二個半徑為150的圓,底部為(0,-150)

第三個半徑為100的圓,底部為(0,-100)

第四個半徑為 ?50的圓,底部為(0, ?-50)

畫的時候按下面的步驟:

擡起畫筆:turtle.penup()

移動到相應坐標:turtle.goto(坐標)

放下畫筆:turtle.pendown()

畫圓:turtle.circle(半徑)

效果如下圖所示:

  • 上一篇:為什麽南紅珠子價格差距大?
  • 下一篇:修模具好學嗎?好找工作嗎?
  • copyright 2024編程學習大全網