因为 a='python'是非空字符串,所以当计算a or 'world'时,a为true,则整个结果必定为true,所以print结果为hello,python;而b是空字符串,计算b or 'world'时,b为false,结果取决于'world',而'world'为true,所以print结果为hello,world。
2015-11-11
def average(*args):
x=sum(args)
n=x/2
return n
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
x=sum(args)
n=x/2
return n
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2015-11-11
print r'''"To be, or not to be": that is the question.
Whether it's nobler in the mind to suffer.'''
Whether it's nobler in the mind to suffer.'''
2015-11-10
s = 'Python was started in 1989 by \"Guido\".\nPython is free and easy to learn.'
print s
print s
2015-11-10
x1 = 1
d = 3
n = 100
x100 = x1 + ( n - 1) * d
s = (x1 + x100) * n / 2
print s
d = 3
n = 100
x100 = x1 + ( n - 1) * d
s = (x1 + x100) * n / 2
print s
2015-11-10
#input code
print 'hello,python.'
print 'hello,','python.'
print 'hello,python.'
print 'hello,','python.'
2015-11-10
#Enter a code
print 45678 + 0x12fd2
print 'Learn Python in imooc'
print 100<99
print 0xff==255
print 45678 + 0x12fd2
print 'Learn Python in imooc'
print 100<99
print 0xff==255
2015-11-10
print [int(str(x)+str(y)+str(x)) for x in range(1,10) for y in range(10) ]
我觉得这样写简单些啊
我觉得这样写简单些啊
2015-11-10
print r'''"To be, or not to be": that is the question.
Whether it's nobler in the mind to suffer.'''
Whether it's nobler in the mind to suffer.'''
2015-11-10
最赞回答 / 小猫过河
<...code...><...code...><...code...><...code...><...code...><...code...><...code...>
2015-11-10
L = [95.5,85,59]
print L[0]
print L[1]
print L[2]
print L
Z正确答案
print L[0]
print L[1]
print L[2]
print L
Z正确答案
2015-11-10