一.使用turtle库绘制一个叠加等边三角形:
import turtle turtle.right(60) turtle.forward(200) turtle.right(120) turtle.forward(200) turtle.right(120) turtle.forward(200) turtle.penup() turtle.forward(-100) turtle.pendown() turtle.right(60) turtle.forward(100) turtle.right(120) turtle.forward(100) turtle.right(120) turtle.forward(100) turtle.done()
二.使用turtle库绘制一个红色五角星:
import turtle turtle.fillcolor("red") turtle.begin_fill() turtle.pensize(2) for i in range (5): turtle.forward(250) turtle.right(144) turtle.end_fill() turtle.done()
三.使用turtle库绘制一个六角形:
import turtle turtle.pensize(3) turtle.pu() turtle.fd(-150) turtle.pd() turtle.left(30) turtle.forward(300) turtle.right(120) turtle.forward(300) turtle.left(60) turtle.forward(-300) turtle.penup() turtle.left(60) turtle.forward(100) turtle.pendown() turtle.left(60) turtle.forward(100) turtle.right(120) turtle.forward(300) turtle.right(120) turtle.forward(300) turtle.right(120) turtle.forward(200) turtle.done()