[root@localhost /]# cat list.py
#!/bin/python
from random import randint
d=[randint(-10,10) for _ in range(10)]
s={'student%d' %i:randint(-10,10) for i in range(10)}
t=[x for x in d if x >=0]
#if (4,3)>(3,4):
# print 'aaaaaaaaaaaa'
r=[(y,x) for x,y in s.items()]
print s
print r
print (sorted(r,reverse=1))
#print s
#print d
#print t
[root@localhost /]#
[root@localhost /]#
[root@localhost /]# cat len.py
#!/bin/python
from collections import Counter
from random import *
a=[randint(1,10) for _ in range(20)]
b={randint(1,10) for _ in range(5)}
c={'student%d' %i:randint(1,20) for i in range(10)}
d=[x for x in a if x>=5]
e={y for y in b if y>=5}
f=[(x,v) for v,x in c.items()]
haha=Counter(a)
str=haha.most_common(3)
print a
print b
print c
print d
print e
print f
print sorted(f)
print str
[root@localhost /]#
阅读(5226) | 评论(0) | 转发(0) |