python123第一周作业_python123第一周作业

1.使用turtle库绘制一个红色五角星图形

import turtle

turtle.pensize(4)

turtle.pencolor("black")turtle.fillcolor("red")

turtle.begin_fill()

for _ in range(5):

turtle.forward(200)

turtle.right(144)turtle.end_fill()

python123第一周作业_python123第一周作业_第1张图片

2.使用turtle库绘制一个六角形

import turtle

turtle.setup(650,350,200,200)

turtle.penup()

turtle.pensize(1)

turtle.pencolor("red")

turtle.fillcolor("yellow")turtle.fd(100)

turtle.seth(30)

turtle.pendown()

turtle.begin_fill()

turtle.fd(80)

turtle.seth(-90)

turtle.fd(80)

turtle.seth(150)

turtle.fd(80)

turtle.end_fill()

turtle.penup()

turtle.seth(30)

turtle.fd(80/3)

turtle.seth(90)

turtle.fd(80/3)

turtle.pendown()

turtle.begin_fill()

turtle.seth(-30)

turtle.fd(80)

turtle.seth(-150)

turtle.fd(80)

turtle.seth(90)

turtle.fd(80)

turtle.end_fill()

python123第一周作业_python123第一周作业_第2张图片

3.使用turtle库绘制一个叠加等边三角形

import turtle

turtle.setup(650,350,200,200)

turtle.penup()

turtle.pensize(1)

turtle.pencolor("red")

turtle.fillcolor("purple")

turtle.begin_fill()

turtle.seth(60)

turtle.pendown()

turtle.fd(50)

turtle.seth(-60)

turtle.fd(100)

turtle.seth(-180)

turtle.fd(100)

turtle.seth(60)

turtle.fd(50)

turtle.seth(0)

turtle.fd(50)

turtle.seth(-120)

turtle.fd(50)

turtle.seth(120)

turtle.fd(50)

turtle.end_fill()

python123第一周作业_python123第一周作业_第3张图片

你可能感兴趣的:(python123第一周作业)