def average(*args):
sum = 0.0
if len(args)!=0:
for a in args:
sum = a +sum
return sum/len(args)
else:
return sum
print sum
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
sum = 0.0
if len(args)!=0:
for a in args:
sum = a +sum
return sum/len(args)
else:
return sum
print sum
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2016-12-25
def greet(a = 0):
if a:
print 'Hello,',a,'.'
else:
print 'Hello,World.'
greet()
greet('Bart')
if a:
print 'Hello,',a,'.'
else:
print 'Hello,World.'
greet()
greet('Bart')
2016-12-25
print r'''"To be, or not to be": that is the question./nWhether it's nobler in the mind to suffer.'''与print r'''"To be, or not to be": that is the question.
Whether it's nobler in the mind to suffer.'''
在练习答案都对,在cmd里面前者不会自动换行/n保留输出,
Whether it's nobler in the mind to suffer.'''
在练习答案都对,在cmd里面前者不会自动换行/n保留输出,
2016-12-25
for x in range(1,10):
for y in range(0,10):
if x<y:
print 10*x+y
for y in range(0,10):
if x<y:
print 10*x+y
2016-12-25
不是说改成内容不可变嘛,,,t = ('a', 'b', ('A', 'B'))这不是指向不变吗?内容。。。这个好水
2016-12-25
但是,如果删除首行 “# -*- coding: utf-8 -*-”,使用 u'''...'''貌似也出错。只有去掉u才好用
2016-12-25