def average(*args):
sum = 0
n = 0
if args:
for x in args:
sum= sum + x
n = n + 1
return sum*1.0/n
else:
return 0
sum = 0
n = 0
if args:
for x in args:
sum= sum + x
n = n + 1
return sum*1.0/n
else:
return 0
2016-11-03
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 看了答案
2016-11-03
已经用utf8 就不用u了 在2.7python中 我直接输入 print '中文' 可以直接编译啊
2016-11-03
最后会出现hello python world 因为a or world时a是非空字符串所以会返回a的值python,在b or world运算中b是空的字符串所以会返回world。
2016-11-03
>>> L = "'Adam',95.5,'Lisa',85,'Bart',59"
>>> print L
'Adam',95.5,'Lisa',85,'Bart',59
>>> print L
'Adam',95.5,'Lisa',85,'Bart',59
2016-11-03
>>> a='python'
>>> print 'hello,',a or 'world'
hello, python
>>> b=''
>>> print 'hello,',b or 'world'
hello, world
>>> print 'hello,',a or 'world'
hello, python
>>> b=''
>>> print 'hello,',b or 'world'
hello, world
2016-11-03
最新回答 / qq_备用郭鹏_04238116
python 3 有很大改进,比 2 更容易理解。 如果题主决定学 2,建议当被 string bytes 搞晕时,了解一下 3,再做决定。另外,3 的库已经比较全了,不支持 3 的,多数是不再维护的。
2016-11-03