zoukankan      html  css  js  c++  java
  • Python基础综合练习(五角星)

    综合练习:画一面五星红旗,将代码与运行截图发布博客交作业。
    import turtle
    
    def mygoto(x,y):
           turtle.up()
           turtle.goto(x,y)
           turtle.down()
    
    def drawwjx(x,y,z):
           turtle.fillcolor('yellow')
           turtle.right(z)
           turtle.forward(y)
           turtle.right(144)
           turtle.begin_fill()
           for i in range(4):
                  turtle.forward(x)
                  turtle.right(144)
           turtle.end_fill()
    
    
    
    turtle.setup(600,400,0,0)
    turtle.bgcolor('red')
    turtle.color('yellow')
    mygoto(-250, 135);
    drawwjx(100,100,0);
    
    
    
    
    mygoto(-120,175);
    drawwjx(30,30,10);
    
    
    mygoto(-85,145);
    drawwjx(30,30,10);
    
    
    mygoto(-85,95);
    drawwjx(30,30,-20);
    
    
    mygoto(-120,65);
    drawwjx(30,30,10);
    
    
    turtle.hideturtle()
    turtle.done()

    字符串练习:

    http://news.gzcc.cn/html/2017/xiaoyuanxinwen_1027/8443.html

    取得校园新闻的编号

    for i in range(2,10,3):
        newspage1='http://news.gzcc.cn/html/xiaoyuanxinwen/{}.html'.format(i)
        print(newspage1)

    练习字符串内建函数:strip,lstrip,rstrip,split,count

    用函数得到校园新闻编号

    url='http://news.gzcc.cn/html/xiaoyuanxinwen_0308/9005.html'
    print(url.strip('.html').split('_')[1])

    用函数统计一歌词(文章、小说)中单词出现的次数,替换标点符号为空格,用空格进行分词。

    url2='Oh oh oh oh oooh Oh oh oh oh oooh Oh oh oh oh oooh Oh oh oh oh oooh I messed up tonight, I lost another fight I still mess up but I ll just start again I keep falling down, I keep on hitting the ground I always get up now to see whats next Birds dont just fly, they fall down and get up Nobody learns without getting it won I wont give up, no I won t give in Til I reach the end, then I ll start again No I wont leave, I wanna try everything I wanna try even though I could fail I wont give up, no I won t give in Til I reach the end and then I ll start again No I won t leave, I wanna try everything I wanna try even though I could fail Oh oh oh oh oooh Try everything Oh oh oh oh oooh Try everything Oh oh oh oh oooh Try everything Oh oh oh oh oooh Look at how far you ve come, you filled your heart with love Baby you ve done enough that cut your breath Dont beat yourself up, dont need to run so fast Sometimes we come last, Til I reach the end and then ll start again No I won'
    print(url2.split())
    print(url2.count('oh'))
    print(url2.lstrip('o'))
  • 相关阅读:
    为什么nhibernate 不能保存ontomany的结构
    如何使用 Mmcv.exe 工具来管理群集消息队列资源[转]
    Building an MSMQ Cluster[转]
    XmlSerializerFactory Is Pretty Cool[转]
    Processing Binary Documents Through BizTalk Via Web Services[转]
    获取数据字典
    Using XPaths in Message Assignment[转]
    MSMQ突破4M限制的方法
    XmlSerializerFactory Is Pretty Cool[转]
    BizTalk自定义证书加密/解密pipeline组件开发
  • 原文地址:https://www.cnblogs.com/wwc000/p/8609576.html
Copyright © 2011-2022 走看看