使用python中turtle的绘制简单图形

eg1:画出如下图像

使用python中turtle的绘制简单图形_第1张图片

import turtle
turtle.showturtle()
turtle.speed(10)
turtle.forward(100)
turtle.penup()
turtle.goto(50,50)
turtle.right(90)
turtle.pendown()
turtle.forward(100)
turtle.done()

eg2:画出如下图像

使用python中turtle的绘制简单图形_第2张图片

import turtle
turtle.showturtle()
turtle.right(60)
turtle.forward(100)
turtle.right(120)
turtle.forward(100)
turtle.right(120)
turtle.forward(100)
turtle.done()

eg3:画出如下图像

使用python中turtle的绘制简单图形_第3张图片

import turtle
turtle.showturtle()
turtle.right(60)
turtle.forward(100)
turtle.right(120)
turtle.forward(100)
turtle.right(120)
turtle.forward(200)
turtle.left(120)
turtle.forward(100)
turtle.left(120)
turtle.forward(100)
turtle.done()

eg4:画出如下图像

使用python中turtle的绘制简单图形_第4张图片

import turtle
turtle.showturtle()
turtle.left(45)
turtle.circle(100,steps=4)
turtle.left(90)
turtle.circle(100,steps=4)
turtle.left(90)
turtle.circle(100,steps=4)
turtle.left(90)
turtle.circle(100,steps=4)
turtle.right(45)
turtle.done()

eg5:画出如下图像

使用python中turtle的绘制简单图形_第5张图片

import turtle
turtle.hideturtle()
turtle.forward(100)
turtle.left(45)
turtle.forward(30)
turtle.left(135)
turtle.forward(100)
turtle.left(45)
turtle.forward(30)
turtle.left(45)
turtle.forward(50)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(50)
turtle.penup()
turtle.goto(0,-50)
turtle.pendown()
turtle.right(45)
turtle.forward(30)
turtle.left(45)
turtle.forward(50)
turtle.penup()
turtle.goto(100,-50)
turtle.right(45)
turtle.pendown()
turtle.forward(30)
turtle.left(45)
turtle.forward(50)
turtle.penup()
turtle.goto(3*(50**0.5),3*(50**0.5)-50)
turtle.pendown()
turtle.right(90)
turtle.forward(100)
turtle.done()

eg6:画出如下图像

使用python中turtle的绘制简单图形_第6张图片

import turtle
turtle.speed(0)
turtle.hideturtle()
turtle.pensize(3)
turtle.circle(100)
turtle.penup()
turtle.goto(0,5)
turtle.write("6")
turtle.penup()
turtle.goto(-90,95)
turtle.pendown()
turtle.write("9")
turtle.penup()
turtle.goto(90,95)
turtle.pendown()
turtle.write("3")
turtle.penup()
turtle.goto(-5,180)
turtle.pendown()
turtle.write("12")
turtle.penup()
turtle.goto(0,100)
turtle.pendown()
turtle.forward(60)
turtle.penup()
turtle.goto(0,100)
turtle.pensize(1)
turtle.pendown()
turtle.left(90)
turtle.forward(70)
turtle.penup()
turtle.goto(-30,-20)
turtle.write("时间 15:00")
turtle.done()

 

你可能感兴趣的:(笔记,python)