第三次作业
List1=['something',28,'qwe',77]#列表的遍历
print(List1)
for a in List1:
    print(a)

Tuple1=('去玩儿童体验')#元祖的遍历
print(Tuple1)
for b in Tuple1:
    print(b)

Set1={1,4,2,3}#集合的遍历
print(Set1)
for c in Set1:
    print(c)

dict1 = {'a':150,'b':685,'c':799}#字典的遍历
print(dict1)
for d in dict1:
    print(d,dict1[d])

结果:

 

英文词频统计:

str='''I've been reading books of old
The legends and the myths
Achilles and his gold
Hercules and his gifts
Spiderman's control
And Batman with his fists
And clearly I don't see myself upon that list
But she said, where'd you wanna go?
How much you wanna risk?
I'm not looking for somebody
With some superhuman gifts
Some superhero
Some fairytale bliss'''
str=str.lstrip()
print(str)

a=str.lower()
print(a)

strList=str.split()
print(len(strList),strList)

strSet=set(strList)

for word in strSet:
   print(word,strList.count(word))

 

 


结果:

 


posted on 2018-10-08 11:28  麦晓志  阅读(97)  评论(0)    收藏  举报