python作业 1、2、3 题
第一题:
import math
import turtle
RADIUS = 100
angleSin18 = math.sin(math.pi * 0.1) * RADIUS
angleCos18 = math.cos(math.pi * 0.1) * RADIUS
angleSin54 = math.sin(math.pi * 0.3) * RADIUS
angleCos54 = math.cos(math.pi * 0.3) * RADIUS
turtle.width(1)
turtle.fillcolor("red")
turtle.begin_fill()
turtle.penup()
turtle.goto(-angleCos18, angleSin18)
turtle.pendown()
turtle.goto(angleCos18, angleSin18)
turtle.goto(-angleCos54, -angleSin54)
turtle.goto(0, RADIUS)
turtle.goto(angleCos54, -angleSin54)
turtle.goto(-angleCos18, angleSin18)
turtle.end_fill()
第二题:
import turtle
turtle.setup(650,350,200,200)
turtle.penup()
turtle.pensize(1)
turtle.pencolor("red")
turtle.fd(100)
turtle.seth(30)
turtle.pendown()
turtle.fd(80)
turtle.seth(-90)
turtle.fd(80)
turtle.seth(150)
turtle.fd(80)
turtle.penup()
turtle.seth(30)
turtle.fd(80/3)
turtle.seth(90)
turtle.fd(80/3)
turtle.pendown()
turtle.seth(-30)
turtle.fd(80)
turtle.seth(-150)
turtle.fd(80)
turtle.seth(90)
turtle.fd(80)
第三题:
import turtle as t
t.setup(600, 600, None,None)
t.pu()
t.fd(-120)
t.pensize(5)
t.width(5)
t.pencolor("darkgreen")
t.pd()
t.fd(250)
t.seth(120)
t.pencolor("black")
t.fd(250)
t.seth(-120)
t.pencolor("blue")
t.fd(250)
t.pencolor("purple")
t.fd(250)
t.seth(0)
t.pencolor("green")
t.fd(250)
t.pencolor("gold")
t.fd(250)
t.seth(120)
t.pencolor("yellow")
t.fd(250)
t.seth(-120)
t.pencolor("grey")
t.fd(250)
t.seth(120)
t.pencolor("pink")
t.fd(250)