import turtle
import random
turtle.setup(300,300)
turtle.bgcolor(random.random(),random.random(),random.random())
turtle.pensize(5)
turtle.up()
turtle.goto(-100,50)
turtle.down()
turtle.pencolor("red")
turtle.fillcolor( 'red')
turtle.begin_fill()
for i in range(5):
turtle.fd(200)
turtle.right(144)
turtle.end_fill()
turtle.bgcolor("black")
turtle.pencolor("yellow")
turtle.fillcolor( 'yellow')
turtle.begin_fill()
for i in range(5):
turtle.fd(200)
turtle.right(144)
turtle.end_fill()
#ps本篇导入两个库
#turtle画图,random随机数
下运行结果
![](https://i-blog.csdnimg.cn/blog_migrate/3c982e434d901ceee17c1ee9ceb1b9f0.png)
![](https://i-blog.csdnimg.cn/blog_migrate/460ddf6551b146d2f182b7e2a781f9ba.png)
![](https://i-blog.csdnimg.cn/blog_migrate/7062b2c7aa92459bf8be50765921a99c.png)