博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
英文词频统计预备,组合数据类型练习
阅读量:4681 次
发布时间:2019-06-09

本文共 1111 字,大约阅读时间需要 3 分钟。

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

aa='''Look at the stars,Look how they shine for you,And everything you do,Yeah, they were all Yellow.I came along,I wrote a song for you,And all the things you do,And it was called Yellow.So then I took my turn,Oh what a thing to have done,And it was all Yellow.Your skinOh yeah, your skin and bones,Turn into something beautiful,You know, you know I love you so,You know I love you so.I swam across,I jumped across for you,Oh what a thing to do.Cos you were all Yellow,I drew a line,I drew a line for you,Oh what a thing to do,And it was all Yellow.'''print(aa.lower())print(aa.replace(',',' '))print(aa.count("yellow"))print(aa.split(" "))

 

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

b=list('3121321321333121112113')b.append('1')b.insert(2,'2')b.pop()b.pop(7)print(b)print('3分的起始位置是',b.index('3'))print('1分的有',b.count('1'),'个')print('3分的有',b.count('3'),'个')

 

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

答:

列表是一种有序的序列,正向递增、反向递减序列,可以随时添加和删除其中的元素,没有长度限制、元素类型可以不同;而元组与列表类似,可读取里面的元素,但是不能改变其中的元素。

转载于:https://www.cnblogs.com/laifai666/p/7576472.html

你可能感兴趣的文章
jmeter(四十四)常用性能指标分析
查看>>
word 新建一行文字不能左对齐
查看>>
jquery选择器
查看>>
IT公司的等级观念
查看>>
百度编辑器ueditor1.4.3配置记录
查看>>
ubuntu12.04开启Framebuffer
查看>>
【问题和解决】python中nltk与nltk_contrib的关系
查看>>
闭包的探索
查看>>
内存泄漏
查看>>
编程之美 2.12 快速寻找满足条件的两个数 解法三证明 (算法导论 第二版 2.3-7 在n个元素的集合S中找到两个和为x的元素)...
查看>>
open_basedir restriction in effect,解决php引入文件权限问题
查看>>
微信小程序获取用户信息解密AES并且注意如何获取unionid
查看>>
JavaScript设计模式----1
查看>>
Qt实现半透明遮罩效果
查看>>
erlang调优方法
查看>>
Mysql linux -N命令
查看>>
daily scrum 12.5
查看>>
linux-ftp install
查看>>
NetXray
查看>>
局域网基本工作原理
查看>>