日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

组合数据类型练习,英文词频统计实例9-21

發(fā)布時間:2024/9/5 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 组合数据类型练习,英文词频统计实例9-21 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
  • 1、列表實例:由字符串創(chuàng)建一個作業(yè)評分列表,做增刪改查詢統(tǒng)計遍歷操作。例如,查詢第一個3分的下標,統(tǒng)計1分的同學有多少個,3分的同學有多少個等。 >>>score=list('21223113321') >>>print('作業(yè)評分列表:',score) >>>score.append('3') >>>print('增加:',score) >>>score.pop() >>>print('刪除:',score) >>>score.insert(2,'1') >>>print('插入:',score) >>>score[2]='2' >>>print('修改:',score) >>>print('第一個3分的下標:',score.index('3')) >>>print('1分的個數(shù):',score.count('1')) >>>print('3分的個數(shù):',score.count('3'))
  • 2、字典實例:建立學生學號成績字典,做增刪改查遍歷操作。 >>>d={'洪英杰':93,'郭子維':74,'王五':45,'徐均鈞':66} >>>print('學生成績字典:',d) >>>d['錢二']=92 >>>print('增加:',d) >>>d.pop('徐均鈞') >>>print('刪除:',d) >>>d['張三']=73 >>>print('修改:',d) >>>print('查詢李四成績:',d.get('李四',''))
  • 3、列表,元組,字典,集合的遍歷。 >>>ls=list("4613125646") >>>tu=tuple("4613125646") >>>s=set("4613125646") >>>d={'洪英杰':93,'郭子維':74,'王五':45,'徐均鈞':66} >>>print("列表:",ls) >>>for i in ls:print(i,end=' ') >>>print("\n") >>>print("元組:",tu) >>>for i in tu:print(i,end=' ') >>>print("\n") >>>print("集合:",s) >>>for i in s:print(i,end=' ') >>>print("\n") >>>print("字典:",d) >>>for i in d:print(i,end='\t') >>>print(d[i],end='\n')
  • 4、英文詞頻統(tǒng)計實例
  • 待分析字符串
  • 分解提取單詞
  • 大小寫 txt.lower()
  • 分隔符'.,:;?!-_’
  • 計數(shù)字典
  • 排序list.sort()
  • 輸出TOP(10)

      • faded = '''You were the shadow to my light Did you feel us? Another start You fade away Afraid our aim is out of sight Wanna see us Alive Where are you now? Where are you now? Where are you now? Was it all in my fantasy? Where are you now? Were you only imaginary? Where are you now? Atlantis Under the sea Under the sea Where are you now? Another dream The monster's running wild inside of me I'm faded I'm faded So lost, I'm faded I'm faded So lost, I'm faded These shallow waters never met what I needed I'm letting go a deeper dive Eternal silence of the sea. I'm breathing alive Where are you now? Where are you now? Under the bright but faded lights You've set my heart on fire Where are you now? Where are you now? Where are you now? Atlantis Under the sea Under the sea Where are you now? Another dream The monster's running wild inside of me I'm faded I'm faded So lost, I'm faded I'm faded So lost, I'm faded'''faded = faded.lower() for i in '?!,.\'\n':faded = faded.replace(i,' ') words = faded.split(' ')dic={} keys = set(words) for i in keys:dic[i]=words.count(i)c = list(dic.items()) c.sort(key=lambda x:x[1],reverse=True)for i in range(10):print(c[i])
      • 建立學生學號成績字典

        >>>score = {10:'41',20:'64',30:'71',40:'81',50:'91'} >>>print(score) >>>score[6] = '90' >>>print(score) >>>score.pop(6) >>>print(score)>>>for i in score:print("{:>2} : {:<2}".format(i,score.get(i)))

        列表,元組,字典,集合

        >>>ls=list("4613125646") >>>tu=tuple("4613125646") >>>se=set("4613125646") >>>d={'阿一':93,'阿二':74,'阿三':45,'阿四':66} >>>print("列表:",ls) >>>for i in ls:print(i,end=' ') >>>print("\n") >>>print("元組:",tu) >>>for i in tu:print(i,end=' ') >>>print("\n") >>>print("集合:",se) >>>for i in se:print(i,end=' ') >>>print("\n") >>>print("字典:",d) >>>for i in d:print(i,end='\t')print(d[i],end='\n')

        歌詞統(tǒng)計

        >>>song = '''Vincent,Don McLean. Starry starry nightpaint your palette blue and greylook out on a summer\'s daywith eyes that know the darkness in my soul.Shadows on the hillssketch the trees and the daffodilscatch the breeze and the winter chillsin colors on the snowy linen land.And now I understandwhat you tried to say to meand how you suffered for your sanityand how you tried to set them free.They would not listen they did not know howperhaps they\'ll listen now.Starry starry nightflaming flowers that brightly blazeswirling clouds in violet hazereflect in Vincent\'s eyes of China blue.Colors changing huemorning fields of amber grainweathered faces lined in painare smoothed beneath the artist\'s loving hand.And now I understandwhat you tried to say to meand how you suffered for your sanityand how you tried to set them free.They would not listen they did not know howperhaps they\'ll listen now.For they could not love youbut still your love was trueand when no hope was left in sight on thatstarry starry night.You took your life as lovers often do,But I could have told you Vincentthis world was never meant for one as beautiful as you.Starry starry nightportraits hung in empty hallsframeless heads on nameless wallswith eyes that watch the world and can\'t forget.Like the stranger that you\'ve metthe ragged men in ragged clothesthe silver thorn of bloddy roselie crushed and broken on the virgin snow.And now I think I knowwhat you tried to say to meand how you suffered for your sanityand how you tried to set them free.They would not listen they\'re not listening stillperhaps they never will.'''>>>song = song.lower() >>>for i in '?!,.\'\n': >>> song = song.replace(i,' ') >>>words = song.split(' ')>>>dic={} >>>keys = set(words) >>>for i in keys: >>>dic[i]=words.count(i)>>>c = list(dic.items()) >>>c.sort(key=lambda x:x[1],reverse=True)>>>for i in range(10):>>>print(c[i])

        ?

轉(zhuǎn)載于:https://www.cnblogs.com/yingja-hong/p/7567595.html

總結(jié)

以上是生活随笔為你收集整理的组合数据类型练习,英文词频统计实例9-21的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 亚洲天堂国产精品 | 国产精品aaa | 2020国产精品视频 | 天天干天天搞天天射 | 毛片一级在线观看 | 97精品人人妻人人 | 人人爽人人爱 | 色四月婷婷 | 久久一二三区 | 欧美日一区二区三区 | 日本欧美在线 | 亚洲区一区二区三区 | 国产黄| 翔田千里一区二区三区av | 日本免费电影一区二区三区 | 黑人狂躁日本妞hd | 小俊大肉大捧一进一出好爽 | 1024日韩 | 国产美女特级嫩嫩嫩bbb | 日韩视频一区二区三区在线播放免费观看 | 国产黄色三级网站 | 国产av天堂无码一区二区三区 | 成人午夜影院 | 精品国产a线一区二区三区东京热 | 亚洲av成人无码一区二区三区在线观看 | 一级作爱片 | 国产精品wwww| av色图 | 伊人青青久 | av久久久| 成人毛片a| 禁断介护av一区二区 | 免费看黄色片视频 | 久久久久久久久91 | 欧美综合在线一区 | 潘金莲一级淫片aaaaa武则天 | 久草免费在线观看视频 | 国产女教师一区二区三区 | 人妖被c到高潮欧美gay | 两女双腿交缠激烈磨豆腐 | 成人福利一区 | 青草草在线视频 | 老鸭窝成人 | 亚洲精品无码一区二区 | 丁香花电影免费播放在线观看 | 国产成人久久精品麻豆二区 | 亚洲精品在线观看av | 国产成人无遮挡在线视频 | 亚洲视频免费播放 | 国产精品一二三四区 | 奇米二区 | 日韩一级特黄 | 中文字幕乱码在线观看 | 国产精品色哟哟 | 国产免费美女 | 亚洲天堂精品一区 | 亚洲AV无码成人精品一区 | 中文字母av | 精品视频999 | h网站免费在线观看 | 国产原创在线 | 天天插视频 | 青草草在线观看 | 久久精品视频久久 | 国产亚洲久久 | 免费久久久| 91丨九色丨蝌蚪丨老版 | 老色驴综合网 | 午夜999| 韩国成人在线视频 | 婷婷国产在线 | 亚洲免费视频大全 | 美国av片| 99精品在线观看 | 亚洲日本精品 | 98av视频| 美女脱了裤子让男人桶 | 亚洲视频一区二区三区 | 中国毛片在线 | 国产香蕉97碰碰碰视频在线观看 | 少妇高潮淫片免费观看 | 二区欧美 | 九九久久精品视频 | 久久免费av | 综合在线观看 | 亚洲第一二三四区 | 欧美一级免费观看 | 久久精品视频播放 | 亚洲天堂免费在线观看视频 | 在线观看污污视频 | 天天干视频在线观看 | 国产农村妇女毛片精品久久 | 精品在线免费视频 | 光棍影院手机版在线观看免费 | 大胸奶汁乳流奶水出来h | 人人干人人澡 | 天天看片天天干 | 免费看裸体视频网站 | 国产欧美久久一区二区三区 |