__MagicPower
Do one thing and do it best!

导航

 
#!/usr/bin/env python 
#--*-- coding:utf-8 --*--

#version one
"""
from random import randint
def odd(n):
    return n%2

allNums = []
for eachNum in range(9):
    allNums.append(randint(1,99))

print allNums
print filter(odd,allNums)
"""

#version two
"""
from random import randint

allNums = []
for eachNum in range(9):
    allNums.append(randint(1,99))

print allNums
print    filter(lambda n:n%2,allNums)
"""
#version three
"""
from random import randint
allNums = []
for eachNum in range(9):
    allNums.append(randint(1,99))
print allNums
print [n for n in allNums if n%2]
"""

#version four
from random import randint as ri
print [n for n in [ri(1,99) for i in range(9)] if n %2]

 

posted on 2015-12-10 13:48  __MagicPower  阅读(169)  评论(0编辑  收藏  举报