CWYAlpha

Just another WordPress.com site

Thought this was cool: 比奥数题还脑残的Python题

leave a comment »


下边的问题是在CPython interactive shell 里按顺序执行的,请在 下划线处 ____ 填上答案。

>>> x = [1, 2, 3]
>>> for number in x:
...     number += 1
... 
>>> print x
__________________
>>> print 1 == True
__________________
>>> print 0 == False
__________________
>>> print 2 == True
__________________
>>> item = 'x'
>>> print item == "y" or "z"
___________________
>>> l = [1,6,4,2,3,9,4,6]
>>> l = l.sort()
>>> print l
___________________
>>> ll = [lambda: n for n in range(5)]
>>> print [l() for l in ll]
___________________
>>> my_gen = (i for i in range(10))
>>> print(3 in my_gen)
___________________
>>> print(7 in my_gen)
___________________
>>> print(2 in my_gen)
___________________

via

from est's blog: http://blog.est.im/post/50388604760

Written by cwyalpha

六月 5, 2013 在 10:38 上午

发表在 Uncategorized

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: