zoukankan      html  css  js  c++  java
  • Python基础综合练习 130

    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))
  • 相关阅读:
    word2vec
    视频推荐系统
    python基础
    go-elasticsearch
    Docker 部署 go项目
    gohbase
    禅道部署linux
    jmeter 报错 Error occurred during initialization of VM Could not reserve enough space for object heap
    jarvis OJ-DSA
    算法-我的第一本算法书(一)
  • 原文地址:https://www.cnblogs.com/hehe2333/p/8601023.html
Copyright © 2011-2022 走看看