zoukankan      html  css  js  c++  java
  • 作业

    1.

    s='''When I am down and oh my soul so weary 
    When troubles come 
    and my heart burdened be 
    Then I am still and wait here in the silence 
    Until you come and sit 
    a while with me. 
    You raise me up, so I can stand on mountains 
    You raise me up, to 
    walk on stormy seas 
    I am strong, when I am on your shoulders 
    You raise me up... 
    to more than I can be 
    You raise me upso 
    I can stand on mountains 
    You raise me up to walk on stormy seas 
    I am strong, when 
    I am on your shoulders 
    You raise me up... 
    to more than I can be 
    You raise me up, so 
    I can stand on mountains 
    You raise me up 
    to walk on stormy seas 
    I am strong, when 
    I am on your shoulders 
    You raise me up... 
    to more than I can be 
    You raise me up, so 
    I can stand on mountains 
    You raise me up, to walk on stormy seas 
    I am strong, when 
    I am on your shoulders 
    You raise me up... 
    to more than I can be 
    You raise me up... 
    to more than I can be '''

    s=s.lower()
    for i in ',.?':
        s=s.replace(i,' ')
    print(s.split(' '))
    print(s.count('talk'))
    print(s.count('anymore'))

    2、列表实例:由字符串创建一个作业评分列表,做增删改查询统计遍历操作。例如,查询第一个3分的下标,统计1分的同学有多少个,3分的同学有多少个等。

    homework=list('134343633')
    for i in range(len(homework)):
    homework[i]=int(homework[i])
    print(homework)
    print(homework.index(6))
    print(homework.count(1))
    print(homework.count(3))

    运行结果:

    [1, 3, 4, 3, 4, 3, 6, 3, 3]
    6
    1
    5

    3、简要描述列表与元组的异同。

    元组和列表十分类似,但是元组是不可变的.
    也就是说你不能修改元组。
    元组通过圆括号中用逗号分割的项目定义。
    元组通常用在使语句或用户定义的函数能够安全地采用一组值的时候,
    即被使用的元组的值不会改变。

  • 相关阅读:
    javascript入门笔记8-window对象
    javascript入门笔记7-计时器
    一篇RxJava友好的文章(二)
    Android 最新学习资料收集
    一篇RxJava友好的文章(一)
    瓣呀,一个基于豆瓣api仿网易云音乐的开源项目
    UStore-自定义JDF文件格式输出
    UStore-添加自定义工作流(JDF)到产品
    XMPie部署与创建过程
    XMPie Tracking 操作
  • 原文地址:https://www.cnblogs.com/lianghaohui123/p/7565482.html
Copyright © 2011-2022 走看看