一、五角星绘制

‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‪‬描述

使用turtle库绘制一个红色五角星图形,如下图所示:‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‪‬

python作业画六角星 python画六角星最简单_python作业画六角星

代码如下:

#五角星绘制
import turtle as t
t.setup(500,500,200,200)
t.penup()
t.fd(-150)
t.pendown()
t.fillcolor("red")
t.begin_fill()
for i in range(5):
    t.fd(300)
    t.right(180-36)
t.end_fill()
t.done()

效果图如下:

python作业画六角星 python画六角星最简单_python作业画六角星_02

 

二、六角形的绘制

‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬描述

使用turtle库绘制一个六角形,效果如下:‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‪‬

 

python作业画六角星 python画六角星最简单_python作业画六角星_03

代码如下:

#绘制六角形
import turtle as t
t.penup()
t.fd(-80)
t.pendown()
t.seth(90)
for i in range(6):
    t.left(60)
    t.fd(100)
    t.right(120)
    t.fd(100)
t.fd(100)
for i in range(5):
    t.right(60)
    t.fd(100)
t.done()

效果图如下:

python作业画六角星 python画六角星最简单_python作业画六角星_04

 

三、叠加等边三角形绘制

‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‪‬描述

使用turtle库绘制一个叠加等边三角形,图形效果如下:‪‬‪‬‪‬‪‬‪‬‮‬‪‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‭‬‪‬

python作业画六角星 python画六角星最简单_python作业画六角星_05

代码如下:

import turtle as t
t.penup()
t.fd(-100)
t.pendown()
t.pensize(5)
t.color("lightpink")
t.seth(-60)
t.fd(200)
t.seth(60)
t.fd(200)
t.seth(-180)
t.fd(200)
t.seth(60)
t.fd(200)
t.seth(-60)
t.fd(400)
t.seth(-180)
t.fd(400)
t.seth(60)
t.fd(200)
t.done()

效果图如下:

python作业画六角星 python画六角星最简单_python作业画六角星_06