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

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

>>> bin='''Put your make up on

Get your nails done

Curl your hair

Run the extra mile

Keep it slim

so they like you, do they like you?

Get your sexy on

Don't be shy, girl

Take it off

This is what you want, to belong, so they like you

Do you like you?

You don't have to try so hard

You don't have to, give it all away

You just have to get up, get up, get up, get up

You don't have to change a single thing

You don't have to try, try, try, try

You don't have to try, try, try, try

You don't have to try, try, try, try

You don't have to try

Yooou don't have to try

Oooh Oooh

Get your shopping on, at the mall, max your credit card

You don't have to choose, buy it all, so they like you

Do they like you?

Wait a second,Why, should you care, what they think of you

When you're all alone, by yourself, do you like you?

Do you like you?You don't have to try so hard

You don't have to, give it all away

You just have to get up, get up, get up, get up

You don't have to change a single thing

You don't have to try so hard

You don't have to bend until you break

You just have to get up, get up, get up, get up

You don't have to change a single thing

You don't have to try, try, try, try

You don't have to try, try, try, try

You don't have to try

You don't have to try

You don't have to try, try, try, try

You don't have to try, try, try, try

You don't have to try, try, try, try

You don't have to tryYooou don't have to try

NooooOooh

You don't have to try so hard

You don't have to, give it all away

You just have to get up, get up, get up, get up

You don't have to change a single thing

You don't have to try, try, try, tryYou don't have to try, try, try, try

You don't have to try, try, try, try

You don't have to try

Take your make up off

Put your head down

Take a breath

Look into the mirror, at yourself.

Don't you like you?

Cause I like you!''
>>> bin=bin.replace(',',' ')
>>> bin=bin.replace('?',' ')

>>> bin=bin.replace('!',' ')

>>> bin=bin.replace('.',' ')

>>> bin.islower()
False
>>> bin=bin.lower()
>>> bin.islower()
True
>>> print(bin.count('try'))
55

>>> print(bin.count('you'))
29

>>> words=bin.split(' ')
>>> print(words)

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

>>> grade=list('1231211233321221221')
>>> grade
['1', '2', '3', '1', '2', '1', '1', '2', '3', '3', '3', '2', '1', '2', '2', '1', '2', '2', '1']

for i in range(len(grade)):
    grade[i]=int(grade[i])
print(grade)

>>>grade.append(2)

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

不同点:元组不可修改,列表可以修改

相同点:除了修改这个点,元组和列表差不多,都可以进行计数,查询等。

转载于:https://www.cnblogs.com/018linbin/p/7562107.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值