英文词频统计预备,组合数据类型练习列表与元组都是容器,是一系列的对象。

实例: 下载一首英文的歌词或文章,将所有,.?!等替换为空格,将所有大写转换为小写,统计某几个单词出现的次数,分隔出一个一个的单词。

wu=‘‘‘KEVIN:
Boy,we made it now we on it.
Think about that time we grindin uh
Nothing‘s changed since that night we pieced up lullaby.
06 now add a 1 to that,
Ten years deep and we still on it.
Like we figured look who left on top the two of .
Could you imagine otherwise?
All that talk about that life we made it come alive.
No regrets or doubts!
Once we say we say we do,
Now the world behind our views,
Seeing the bigger picture man,
I knew the end it be the two.
KRIS:
Ye!
End will be the two,
You know we got the views,
I need some real reviews,
Tell me the truth what else I gotta do.
Don‘t wanna be stayin in the shadow rear mirror view.
别告诉我你想要的想做的想说的
我在乎我想要的想做的想得到的
我活着就是为了看看天有多高
Cause we got the sauce and we started from the bottom
Right about now!
I‘ll smile don‘t wanna see u cry!
Just sing me a lullaby.
I‘ll cry for u to see ur smile,
This will be my lullaby.
I‘ll smile don‘t wanna see u cry!
Just sing me a lullaby!
I‘ll cry for u to see ur smile.
This will be my lullaby.
他们说我们其实都是一样的
面对家人我们表现都是叛逆的
只有当我真正的明白
你的付出全都是为了我将来
其实我一直都想成为一个good boy
有时不敢回家是因为害怕
我们的争吵会持续蔓延
我也害怕有天看你白发苍苍
对着我微笑的脸no!
KEVIN:
Didn‘t think a chimney would get me so deep run and chasin‘,
What seem to be fantasies ain‘t wasted,
Look at time fly by tick the clock counter-wise,
Now is just a moment caught picture perfect god,
Man patience u said was a virtue!
Maybe that‘s why the fire never dimmed and pursued,
Into something even God himself couldn‘t presume,
But thanks to you I stand here the dream continues.
KRIS:
I‘ll smile don‘t wanna see u cry,
Just sing me a lullaby.
I‘ll cry for u to see ur smile,
This will be my lullaby.
I‘ll smile don‘t wanna see u cry,
Just sing me a lullaby.
I‘ll cry for u to see ur smile,
This will be my lullaby.
I‘ll smile don‘t wanna see u cry,
Just sing me a lullaby.
I‘ll cry for u to see ur smile,
This will be my lullaby.
I‘ll smile don‘t wanna see u cry,Just sing me a lullaby.
I‘ll cry for u to see ur smile.
This will be my lullaby!‘‘‘
k =wu.lower()
r =k.replace(‘.‘,‘ ‘)
i =r.replace(‘!‘,‘ ‘)
s =i.replace(‘?‘,‘ ‘)
w =s.replace(‘,‘,‘ ‘)
u =w.split(‘ ‘)
print(‘cry的次数‘,u.count(‘cry‘))
print(‘lullaby次数‘,u.count(‘lullaby‘))

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

>>> lst=list(‘123123321‘)
>>> lst
[‘1‘, ‘2‘, ‘3‘, ‘1‘, ‘2‘, ‘3‘, ‘3‘, ‘2‘, ‘1‘]
>>> lst.append(‘6‘)
>>> lst
[‘1‘, ‘2‘, ‘3‘, ‘1‘, ‘2‘, ‘3‘, ‘3‘, ‘2‘, ‘1‘, ‘6‘]
>>> lst.pop(6)
‘3‘
>>> lst
[‘1‘, ‘2‘, ‘3‘, ‘1‘, ‘2‘, ‘3‘, ‘2‘, ‘1‘, ‘6‘]
>>> lst.insert(1,‘6‘)
>>> lst
[‘1‘, ‘6‘, ‘2‘, ‘3‘, ‘1‘, ‘2‘, ‘3‘, ‘2‘, ‘1‘, ‘6‘]
>>> lst.pop(2)
‘2‘
>>> lst
[‘1‘, ‘6‘, ‘3‘, ‘1‘, ‘2‘, ‘3‘, ‘2‘, ‘1‘, ‘6‘]
>>> lst.index(‘3‘)
2
>>> lst
[‘1‘, ‘6‘, ‘3‘, ‘1‘, ‘2‘, ‘3‘, ‘2‘, ‘1‘, ‘6‘]
>>> lst.count(‘1‘)
3
>>> lst
[‘1‘, ‘6‘, ‘3‘, ‘1‘, ‘2‘, ‘3‘, ‘2‘, ‘1‘, ‘6‘]
>>> lst.count(‘3‘)
2

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

答:异:元组一旦被赋值,值不可以被改变,一旦改变就会出错;但是列表可以任意的更改。

其次是他们用不同的符号表示,复制的时候,列表用方括号[],而元组用小括号()。

同:列表与元组都是容器,是一系列的对象。

时间: 2024-08-28 21:22:12

英文词频统计预备,组合数据类型练习列表与元组都是容器,是一系列的对象。的相关文章

英文词频统计预备 组合数据类型练习

1.实例: 下载一首英文的歌词或文章,将所有,.?!等替换为空格,将所有大写转换为小写,统计某几个单词出现的次数,分隔出一个一个的单词. big='''OoohOooh Put your make-up onGet your nails doneCurl your hairRun the extra mileKeep it slim so they like you, do they like you? Get your sexy onDon't be shy, girlTake it offT

英文词频统计预备,组合数据类型练习

1.实例: 下载一首英文的歌词或文章,将所有,.?!等替换为空格,将所有大写转换为小写,统计某几个单词出现的次数,分隔出一个一个的单词. lyrics='''Waking up I see that everything is okay The first time in my life and now it's so great Slowing down I look around and I am so amazed I think about the little things that

作业7——英文词频统计预备,组合数据类型练习

1.实例: 下载一首英文的歌词或文章,将所有,.?!等替换为空格,将所有大写转换为小写,统计某几个单词出现的次数,分隔出一个一个的单词./ abc='''Models from different countries took to the catwalk in qipao, a traditional Chinese dress, at the first Shenyang Qipao International Cultural Festival held at the Shenyang P

组合数据类型练习,英文词频统计实例上列表,元组,字典,集合的遍历。 总结列表,元组,字典,集合的联系与区别。

1.字典实例:建立学生学号成绩字典,做增删改查遍历操作. d={'天':95,'青':78,'色':65,'等':66}print('学生成绩字典:',d)d['烟']=98print('增加:',d)d.pop('等')print('删除:',d)d['天']=78print('修改:',d)print('查询青成绩:',d.get('青','无')) 2.列表,元组,字典,集合的遍历.总结列表,元组,字典,集合的联系与区别. s=list('123456789')t=set('7564231

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

字典实例:建立学生学号成绩字典,做增删改查遍历操作. #创建一个空字典 dict={} s=dict print(s) #增加键值对(学号-成绩) s['001']=60 s['002']=70 s['003']=80 s['004']=90 print(s) #删除 s.pop('004') print(s) #修改 s['001']=69 print(s) #查找键是否存在 s.get('005','不存在') print(s) #便历 for i in s: print(i) 2.列表,元

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

1.由字符串创建一个作业评分表,做增删改查询统计遍历操作,例如查询第一个3分的下标,统计1分的同学有几个,3分的同学有几个,增删改查等等. 2.字典实例:建立学生学号成绩字典,做增删改查遍历操作. 3.列表,元组,字典,集合的遍历. 4.英文词频统计实例 news = '''When I was young I'd listen to the radio Waiting for my favorite songs When they played I'd sing along, It make

组合数据类型和英文词频统计实例

1.列表实例:由字符串创建一个作业评分列表,做增删改查询统计遍历操作.例如,查询第一个3分的下标,统计1分的同学有多少个,3分的同学有多少个等. >>> ls=list('1231323232323131323') >>> ls ['1', '2', '3', '1', '3', '2', '3', '2', '3', '2', '3', '2', '3', '1', '3', '1', '3', '2', '3'] >>> ls.append('4'

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

1,建立学生学号成绩字典,做增删改查遍历操作. #创建 d={'01':73,'02':98,'03':66,'04':88,'05':73} d {'01': 73, '02': 98, '03': 66, '04': 88, '05': 73} #查找 >>> d['04'] 88 #插入 >>> d['06']='75' >>> d {'01': 73, '02': 98, '03': 66, '04': 88, '05': 73, '06':

八、组合数据类型练习,英文词频统计实例上

1.字典实例:建立学生学号成绩字典,做增删改查遍历操作. dict={'001':'66','003':'77','006':'88','009':'99'} print('学生学号成绩:',dict) dict['007']=96 print('增加学号为007的学生的成绩为96:',dict) dict.pop('001') print('删除学号为001的学生的记录:',dict) dict['007']=100 print('修改学号为007的学生的成绩为100:',dict) prin