1,生成多个随机数,并升序排列
import numpy as np
s=np.random.randint(1,100,size=10)#随机生成1到100中的整数,组成一维数组
print(sorted(s))#正向排序,升序
print(sorted(s,reverse=True))#逆序
python数组排序用python内置的sorted函数就可以实现
sorted()函数中的reverse参数为True时就是逆序排序
2.统计重复单词出现的次数
import collections
#从Collections集合模块中引入集合类Counter
h=“hello,python,hello,world”
word=h.split(",")
#split() 通过指定分隔符对字符串进行切片
#print(word)
m=collections.Counter(word)
#counter可以计数数组内所有元素出现的次数
print(m)