or:
print(0 or 55) , 结果输出55
print(55 or 0), 结果输出55
print(None or 55) , 结果输出55
print(55 or None), 结果输出55
print('' or 55) , 结果输出55
print(55 or ''), 结果输出55
print(22 or 55) , 结果输出22
print(55 or 22), 结果输出55
print(0 or 55) , 结果输出55
print(55 or 0), 结果输出55
print(None or 55) , 结果输出55
print(55 or None), 结果输出55
print('' or 55) , 结果输出55
print(55 or ''), 结果输出55
print(22 or 55) , 结果输出22
print(55 or 22), 结果输出55
2019-09-17
and:
print(0 and 55), 结果输出0, (先运行到0,发现false, 那一定是false,后面不用继续)
print(55 and 0), 结果输出0, (先运行到55,发现true,结果取决于后面,继续运行)
print(None and 55) , 结果输出None
print(55 and None), 结果输出None
print('' and 55) , 结果输出为空
print(55 and ''), 结果输出为空
print(22 and 55), 结果输出55
print(55 and 22), 结果输出22
print(0 and 55), 结果输出0, (先运行到0,发现false, 那一定是false,后面不用继续)
print(55 and 0), 结果输出0, (先运行到55,发现true,结果取决于后面,继续运行)
print(None and 55) , 结果输出None
print(55 and None), 结果输出None
print('' and 55) , 结果输出为空
print(55 and ''), 结果输出为空
print(22 and 55), 结果输出55
print(55 and 22), 结果输出22
2019-09-17
def average(*args):
if len(args) == 0:
return 0.0
return float(sum(args))/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
if len(args) == 0:
return 0.0
return float(sum(args))/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2019-09-17
已采纳回答 / 丶南柯旧梦
这种写法相当于走了两次迭代,第一次for x in range(1,100,2),第二次for y in range(2,100,2),结果有49*48个,和题目要求不一样,不单单是编译器版本问题
2019-09-17
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.'''
2019-09-17
L = ['Adam', 'Lisa', 'Bart']
L[2],L[0]=L[0],L[2]
print L
L[2],L[0]=L[0],L[2]
print L
2019-09-16