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'))
  • 相关阅读:
    .net序列化和反序列化(一)——自动序列化
    在Sql Server 2005使用公用表表达式CTE简化复杂的查询语句
    使用JQuery与iframe交互
    FCKeditor自定义工具栏和定义多个工具栏
    FCKeditor自定义非空验证
    PHP5.3.6的IIS配置
    Linux下缓存服务器的应用
    PHP采集程序中常用的函数
    关于PHP5.3.x和Zend Optimizer(Zend Guard Loader),以及shopex4.8.5安装的问题
    SQLserver数据库还原出现错误112(磁盘空间不足)的解决办法
  • 原文地址:https://www.cnblogs.com/wwc000/p/8609576.html
Copyright © 2011-2022 走看看