#1.画出奥运五环 import turtle #导入turtle模块 turtle.width('8') #设置画线的宽度 turtle.penup() #抬笔路径,画不出来 turtle.goto(-150,0) #移动到坐标(-150,0) turtle.pendown() #下笔,显示路径 turtle.color('blue') #显示路径颜色为blue turtle.circle(50) #画圆 turtle.penup() turtle.goto(-30,0) turtle.pendown() turtle.color('black') turtle.circle(50) turtle.penup() turtle.goto(90,0) turtle.pendown() turtle.color('red') turtle.circle(50) turtle.penup() turtle.goto(-90,-40) turtle.pendown() turtle.color('yellow') turtle.circle(50) turtle.penup() turtle.goto(30,-40) turtle.pendown() turtle.color('green') turtle.circle(50)
2.画出4个矩形
import turtle #导入turtle模块
#第一个矩形
turtle.color('red') #设置路径颜色为红色
turtle.penup()
turtle.goto(-100,0)
turtle.pendown()
turtle.forward(50) #向前移动50
turtle.left(90) #向左旋转90度
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
#第二个矩形
turtle.penup()
turtle.goto(-40,50)
turtle.pendown()
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
#第三个矩形
turtle.penup()
turtle.goto(-50,-10)
turtle.pendown()
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
#第四个矩形
turtle.penup()
turtle.goto(10,-60)
turtle.pendown()
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(50)