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

    画一面五星红旗,将代码与运行截图发布博客交作业

    import turtle
    t = turtle.Pen();
    t.hideturtle()
    #移动笔
    def mygoto(x, y):
        t.up()
        t.goto(x, y)
        t.down()
    #画五角星
    def dramfive(x):
        t.begin_fill()
        for i in range(5):
            t.forward(x);
            t.right(144);
        t.end_fill();
    
    t.speed(5);
    t.pensize(1);
    #红色国旗
    t.color('red');
    mygoto(-300,250)
    t.begin_fill()
    for i in range(2):
        t.forward(600)
        t.right(90)
        t.forward(400)
        t.right(90)
    t.end_fill()
    
    #大五角星
    t.color('yellow');
    mygoto(-260,180)
    dramfive(120)
    
    #小五角星
    for i in range(4):
       x=1
       if i in[0,3]:
          x = 0
       mygoto(-120+x*40,220-i*40)
       t.left(15-i*15)
       dramfive(30)
    
    turtle.done();
    

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

    取得校园新闻的编号

    str1 ="http://news.gzcc.cn/html/2017/xiaoyuanxinwen_1027/8443.html"
    print(str1[-9:-5])
    

    https://docs.python.org/3/library/turtle.html

    产生python文档的网址

    str2 ="https://docs.python.org/3/library/turtle.html"
    print(str2.replace("turtle","python"))
    

    http://news.gzcc.cn/html/xiaoyuanxinwen/4.html

    产生校园新闻的一系列新闻页网址

    area1 = "http://news.gzcc.cn/html/xiaoyuanxinwen/"
    area2 = ".html"
    for i in range(2,10):
       area = area1 + str(i) + area2
       str3 = "http://news.gzcc.cn/html/xiaoyuanxinwen/{}.html".format(i)
       print(str3,area)
    

    用函数得到校园新闻编号

    str4 ="http://news.gzcc.cn/html/2017/xiaoyuanxinwen_1027/8443.html"
    print (str4.split('_',2)[1].rstrip(".html"))
    

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

    str5 = '''You do the Hokey Pokey and you turn yourself around.
     That‟s what it‟s all about.
     You put your right foot in, you put your right foot out.
     You put your right foot in, and you shake it all about.
     You do the Hokey Pokey and you turn yourself around.
     That‟s what it‟s all about.
     You put your left foot in, you put your left foot out.
     You put your left foot in, and you shake it all about.
     You do the Hokey Pokey and you turn yourself around.
     That‟s what it‟s all about.
     You put your whole self in, you put your whole self out.
     You put your whole self in, and you shake it all about.
     You do the Hokey Pokey and you turn yourself around.
     That‟s what it‟s all about.'''
    
    print(str5.count("you"));
    print(str5.replace("."," "))
    print(str5.split())
    

      

  • 相关阅读:
    K8S 使用NFS 创建PV和PVC的例子 学习From https://blog.csdn.net/xts_huangxin/article/details/51494472
    Windows 2012r2 以及以上版本远程提示错误的解决方法
    CentOS下 NFS的简单使用以及windows 关在linux的NFS存储方法
    PPT 遥控器
    Windows 下面简单的同步文件夹工具
    IIS 下 搭建简单的FTP服务器
    Zoom 会议系统
    SQLSERVER 2014 内存优化表相关
    SQLSERVER 2014 SP1 的服务器 日志文件无法收缩的处理
    Jenkins Jfrog Artifactory 以及docker下的pipeline 容器编排实践
  • 原文地址:https://www.cnblogs.com/lgy520/p/8609932.html
Copyright © 2011-2022 走看看