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))

    运行结果

     
  • 相关阅读:
    房地产行业的商业智能BusinessIntelligence介绍
    企业混搭应用介绍
    ElasticSearch+NLog+Elmah实现Asp.Net分布式日志管理
    如何寻找“真爱”型合伙人
    微信转发朋友圈小视频就这么简单
    微信 6.5.1 for iOS发布 可以在朋友圈分享相册中的视频
    微信养号教程预防封号
    首场微信小论坛上他们都聊了哪些小程序的议题
    搜狗微信搜索增加平均阅读数和发文数
    微信小程序想要的是无法监测的流量dark social
  • 原文地址:https://www.cnblogs.com/didi-l/p/9712266.html
Copyright © 2011-2022 走看看