zoukankan      html  css  js  c++  java
  • 第三次作业

    一.列表,元组,字典,集合的遍历

    #列表的遍历
    List1=['Tracy',20,'Amy',10]
    print(List1)
    for a in List1:
        print(a)
    #元组的遍历
    Tuple1=('你今天真好看')
    print(Tuple1)
    for b in Tuple1:
        print(b)
    #集合的遍历
    Set1={1,2,3,4}
    print(Set1)
    for c in Set1:
        print(c)
    #字典的遍历
    dict1 = {'a':80,'b':79,'c':90}
    print(dict1)
    for d in dict1:
        print(d,dict1[d])

    运行结果

    二.英文词频统计

    str1='''It's a Beautiful Night We'Re Looking For Something Dumb To Do
    Hey Baby i Think i Wanna Marry You
    Is It The Look In Your Eyes Or Is It This Dancing Juice
    Who Cares Baby i Think i Wanna Marry You
    Well i Know This Little Chapel On The Boulevard
    We Can Go Whoa Whoa
    No One Will No Whoa
    Oh Come On Girl
    Who Cares If We'Re Trashed
    Got a Pocket Full Of Cash We Can Blow Whoa Whoa
    Shots Of Patrol Whoa Whoa
    And Guitar Girl
    Don't Say No No No No No
    Just Say Yeah Yeah Yeah Yeah Yeah
    And We'Ll Go Go Go Go Go
    If You'Re Ready Like i'm Ready
    Cos It's a Beautiful Nigt We'Re Looking For Something Dumb To Do
    Hey Baby i Think i Wanna Marry You
    Is It The Look In Your Eyes Or Is It This Dancing Juice
    Who Cares Baby i Think i Wanna Marry You
    Oh
    i'Ll Go Get The Ring
    Let The Choir Bell Sing Like Ooh Ooh Ooh
    So What You Wanna Do Ooh Ooh
    Lets Just Run Girl
    If We Wake Up And You Want To Break Up
    That's Cool Ooh Ooh
    No i Won't Blame You Ooh Ooh
    It Was Fun Girl
    Don't Say No No No No No
    Just Say Yeah Yeah Yeah Yeah Yeah
    And We'Ll Go Go Go Go Go
    If You'Re Ready Like i'm Ready
    Cos It's a Beautiful Night We'Re Looking For Something Dumb To Do
    Hey Baby i Think i Wanna Marry You
    Is It The Look In Your Eyes Or Is It This Dancing Juice
    Who Cares Baby i Think i Wanna Marry You
    Just Say i Do Ooh Ooh Ooh
    Tell Me Right Now Baby
    Tell Me Right Now Baby Baby
    Just Say i Do Ooh Ooh Ooh
    Tell Me Right Now Baby
    Tell Me Right Now Baby Baby
    Oh
    It's a Beautiful Night We'Re Looking For Something Dumb To Do
    Hey Baby i Think i Wanna Marry You
    Is It The Look In Your Eyes Or Is It This Dancing Juice
    Who Cares Baby i Think i Wanna Marry You'''
    #歌曲中去掉空格
    str1=str1.lstrip()
    print(str1)
    #把单词全部变成小写
    a=str1.lower()
    print(a)
    #将歌词的每个单词分隔
    strList=str1.split()
    print(len(strList),strList)
    #用set把字符串转换成集合
    strSet=set(strList)
    #计算每个单词出现的次数
    for word in strSet:
       print(word,strList.count(word))

    运行结果

     
  • 相关阅读:
    前端进阶之js执行顺序
    使用editorconfig自定义编辑器中的代码格式
    如何超简单搭建自己的个人网站博客并发布(github+netify+gitbook)
    网站开发对于IE8以下版本浏览器一般怎样处理
    响应式布局中单位选择(px、em、rem)
    个人网站可以加哪些好看的动效
    使用editorconfig自定义编辑器中的代码格式
    前端开发必会的响应式布局
    python自动化测试学习目录
    拥有心动的jmeter图表报告
  • 原文地址:https://www.cnblogs.com/didi-l/p/9712266.html
Copyright © 2011-2022 走看看