Python基础综合练习

import turtle
import math

'''
@x,y 五角星中点
@width 五角星中点到某一个锐角的距离
@degree 顺时针旋转的角度
'''
def drawFivePointedStar(x,y,width,degree):
    x1=x+math.cos((162-degree)/180*math.pi)*width
    y1=y+math.sin((162-degree)/180*math.pi)*width
    Mygoto(x1, y1)
    turtle.begin_fill()
    turtle.setheading(-degree)
    size=width*2*math.cos(18*math.pi)
    for _ in range(5):
        turtle.forward(size)
        turtle.right(144)
    turtle.end_fill()

def Mygoto(x,y):
    turtle.up()
    turtle.goto(x, y)
    turtle.down()

#设置画布
turtle.screensize(400,400, "red")
#五角星颜色
turtle.pencolor("yellow")
turtle.fillcolor("yellow")
#主角位置
x=-150
y=100
#主角
drawFivePointedStar(x,y,100,0)
#副角
for index in range(4):
    #设置副角位于主角中心的角度,求出副角中心位置
    degree=25*3/2-25*index
    x1 = x + math.cos(degree/ 180 * math.pi) * 200
    y1 = y + math.sin(degree/ 180 * math.pi) * 200
    #求出副角自身旋转角度,使其一个锐角指向主角中心
    drawFivePointedStar(x1, y1, 30, -degree-18)
turtle.done()

 

str = 'http://news.gzcc.cn/html/2017/xiaoyuanxinwen_1027/8443.html'
print(str[-14:-5])
addr1 = 'https://docs.python.org/3.6/library/'
addr2 = '.html'
addr = addr1 + 'turtle' + addr2
print(addr)
for i in range(2,229):
    print('http://news.gzcc.cn/html/xiaoyuanxinwen/{}.html'.format(i))

 

posted @ 2018-03-19 11:39  130-张煌  阅读(157)  评论(0编辑  收藏  举报