def average(*args):
if len(args)==0:
return 0.0
else:
return (sum(args)*1.0/len(args))
print (average())
print (average(1, 2))
print (average(1, 2, 2, 3, 4))
if len(args)==0:
return 0.0
else:
return (sum(args)*1.0/len(args))
print (average())
print (average(1, 2))
print (average(1, 2, 2, 3, 4))
2019-11-11
print [int(m+n+m) for m in '123456789' for n in '0123456789']
2019-11-10
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
L.pop(2)
print L
和
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(3)
L.pop(2)
print L
L.pop(2)
L.pop(2)
print L
和
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(3)
L.pop(2)
print L
2019-11-07
Python次方表示是“**”
sum = 0
x = 1
n = 1
while True:
sum +=x
n = n +1
x=2**(n-1)
if n > 20:
break
print sum
sum = 0
x = 1
n = 1
while True:
sum +=x
n = n +1
x=2**(n-1)
if n > 20:
break
print sum
2019-11-07