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

 下载一首英文的歌词或文章,将所有大写转换为小写,,将所有其他做分隔符(,.?!)替换为空格,并统计某些单词出现的次数。

s='''every night in my dreams 
i see you, i feel you,
that is how i know you go on 
far across the distance 
and spaces between us 
you have come to show you go on 
near, far, wherever you are 
i believe that the heart does go on 
once more you open the door 
and you're here in my heart 
and my heart will go on and on 
love can touch us one time 
and last for a lifetime 
and never let go till we're one 
love was when i loved you 
one true time i hold to 
in my life we'll always go on 
near, far, wherever you are 
i believe that the heart does go on 
once more you open the door 
and you're here in my heart 
and my heart will go on and on 
there is some love that will not go away 
you're here, there's nothing i fear,
and i know that my heart will go on 
we'll stay forever this way 
you are safe in my heart 
and my heart will go on and on'''
s=s.lower()
s.replace(',',' ')
words=s.split(' ')
print(words)
print(s.count('go'))

 

由字符串创建一个作业评分列表,做增删改查询统计遍历操作。

全部改为数值型
查询第一个3分的下标
1分的同学有多少个,3分的同学有多少个

s=['1','2','3','2','2','1']
print(type(s))
print(s)
print(s[0])
s[1]='3'
print(s)
print(len(s))
s.append('2')
print(s)
print(max(s))
s.insert(0,'3')
print(s)

print(list(s))
d=list(s)
print(d)
b=list('123221')
print(b)
f=('1','2','3','2','2','1')
print(f)
print(f.count('1'))
print(f.count('3'))

 

  1. 简要描述列表与元组的异同。
  2. 列表里的元素可以修改,元祖里的元素只能查询不能修改
posted @ 2017-09-22 11:45  092曹馨文  阅读(136)  评论(0编辑  收藏  举报