1. 画正方形
import turtle

t = turtle.Turtle()
t.speed(0)

for i in range(4):
    t.forward(100)
    t.right(90)

turtle.done()
  1. 画三角形
import turtle

t = turtle.Turtle()
t.speed(0)

for i in range(3):
    t.forward(100)
    t.right(120)

turtle.done()
  1. 画圆形
import turtle

t = turtle.Turtle()
t.speed(0)

t.circle(50)

turtle.done()
  1. 画五角星
import turtle

t = turtle.Turtle()
t.speed(0)

for i in range(5):
    t.forward(100)
    t.right(144)

turtle.done()
  1. 画六角星
import turtle

t = turtle.Turtle()
t.speed(0)

for i in range(6):
    t.forward(100)
    t.right(60)

turtle.done()
  1. 画螺旋线
import turtle

t = turtle.Turtle()
t.speed(0)

for i in range(100):
    t.forward(i)
    t.right(10)

turtle.done()
  1. 画心形
import turtle

t = turtle.Turtle()
t.speed(0)

t.left(45)
t.forward(100)
t.circle(50, 180)
t.right(90)
t.circle(50, 180)
t.forward(100)

turtle.done()
  1. 画菱形
import turtle

t = turtle.Turtle()
t.speed(0)

for i in range(2):
    t.forward(100)
    t.right(45)
    t.forward(100)
    t.right(135)

turtle.done()
  1. 画正多边形
import turtle

t = turtle.Turtle()
t.speed(0)

sides = 6 # 此处可以改变边数

angle = 360 / sides

for i in range(sides):
    t.forward(100)
    t.right(angle)

turtle.done()
  1. 画蜘蛛网
import turtle

t = turtle.Turtle()
t.speed(0)

for i in range(6):
    t.circle(100)
    t.right(60)

turtle.done()
  1. 画箭头
import turtle

t = turtle.Turtle()
t.speed(0)

t.forward(100)
t.right(135)
t.forward(50)
t.left(90)
t.forward(50)
t.right(135)
t.forward(100)

turtle.done()
  1. 画扇形
import turtle

t = turtle.Turtle()
t.speed(0)

t.circle(100, 60)

turtle.done()
  1. 画三角波形
import turtle

t = turtle.Turtle()
t.speed(0)

for i in range(10):
    t.forward(50)
    t.right(120)
    t.forward(50)
    t.left(120)

turtle.done()
  1. 画叶子形状
import turtle

t = turtle.Turtle()
t.speed(0)

for i in range(2):
    t.circle(50, 90)
    t.circle(10, 90)

turtle.done()
  1. 画立方体
import turtle

t = turtle.Turtle()
t.speed(0)

for j in range(4):
    t.forward(100)
    t.right(90)

t.right(45)
t.forward(71)
t.right(135)

for j in range(4):
    t.forward(100)
    t.right(90)

turtle.done()
``
python39 用turtle库画15个好玩的图形

原文地址: https://www.cveoy.top/t/topic/dcC5 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录