The code:
# part 1
import turtle
STARTING_X, STARTING_Y = 350, 200
turtle.penup()
turtle.width(2)
turtle.setheading(180)
turtle.sety(STARTING_Y)
# part 2
for a in range(1, 8):
turtle.penup()
turtle.setx(STARTING_X)
for b in range(a): # part 3
turtle.pendown()
turtle.circle(25)
turtle.penup()
turtle.forward(60)
turtle.sety(turtle.ycor() - 60)
turtle.done()
Part 1:
- Importing turtle
- Making global variables for starting positions
- turtle stuff (read docs)
Part 2:
- for loop that runs 8 times
- turtle pen up (not drawing)
- start at predefined x position
- for loop (see Part 3)
- lower the y position with 60
Part 3:
runs a
times
turtle pendown (drawing)
drawing a circle
turtle penup (not drawing)
go forward with 60 (in this case, lower the x position with 60 because of the direction in part 1)
**Summary**
This program draws 8 lines of circles, and each nth line contains n circles aligned to the right like this:
*
**
***
****
*****
******
*******
********
But circles instead of stars
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…