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

    Pycharm开发环境设置与熟悉。

    练习基本输入输出:

    print('你好,{}.'.format(name))

    print(sys.argv)

    库的使用方法:

    import ...

    from ... import ...

    条件语句:

        if (abs(pos()))<1:

            break

    循环语句:

    for i in range(5):

    while True:

    函数定义:

    def mygoto(x,y):

    def drawjx(r):

    综合练习:画一面五星红旗,将代码与运行截图发布博客交作业。

    import turtle
    
    def goto(x,y):
        turtle.up();
        turtle.goto(x,y);
        turtle.down;
    
    def drawxwjx(x):
        turtle.begin_fill()
        for i in range(5):
            turtle.forward(x)
            turtle.right(144)
        turtle.end_fill()
    
    turtle.setup(600,400,0,0)
    turtle.color("yellow")
    turtle.bgcolor("red")
    
    goto(-260,120)
    turtle.begin_fill()
    for i in range(5):
        turtle.forward(100)
        turtle.right(144)
    turtle.end_fill()
    
    for i in range(4):
        x = 1
        if i in [0,3]:
            x = 0
        goto(-120+x*45,180-i*45)
        turtle.left(15-i*15)
        drawxwjx(30)
    
    turtle.hideturtle()
    
    turtle.done()
    

    字符串练习:

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

    取得校园新闻的编号

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

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

    产生python文档的网址

    addr1 = 'https://docs.python.org/3/library/'
    addr2 = '.html'
    addr = addr1 + 'turtle' +  addr2
    print(addr)
    

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

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

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

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

    用函数得到校园新闻编号

    用函数统计一歌词中单词出现的次数

  • 相关阅读:
    下载ORACLE中BLOB内容到客户端
    VIEW_PK
    带下拉框的GridView的OnRowEditing
    HyperLinkField
    ArcEngine开发 退出系统报错
    【转载】Winform 中的控件透明设置要点
    【转载】大整数相乘
    c# oracle 分页
    view_fk
    ITopologicalOperator Intersect
  • 原文地址:https://www.cnblogs.com/wlh0329/p/8610995.html
Copyright © 2011-2022 走看看