这个可以通过
def average(*args):
if sum(args) != 0:
av = float(sum(args)) / float(len(args))
return av
else:
return 0.0
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
def average(*args):
if sum(args) != 0:
av = float(sum(args)) / float(len(args))
return av
else:
return 0.0
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2015-04-22
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
L.pop()
print L
L.pop(2)
L.pop()
print L
2015-04-22
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
L.pop(2)
print L
L.pop(2)
L.pop(2)
print L
2015-04-22
x1 = 1
d = 3
n = 100
x100 = x1+(n-1)*d
s = (x100+x1)*n/2
print s
d = 3
n = 100
x100 = x1+(n-1)*d
s = (x100+x1)*n/2
print s
2015-04-21
score = 75
if score >= 60:
print "Bart's score is",score
print 'passed'
print 'END'
if score >= 60:
print "Bart's score is",score
print 'passed'
print 'END'
2015-04-21
import math
def quadratic_equation(a, b, c):
det=math.sqrt(b * b - 4 * a * c);
return (-b + det)/(2*a), (-b-det)/(2*a);
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
def quadratic_equation(a, b, c):
det=math.sqrt(b * b - 4 * a * c);
return (-b + det)/(2*a), (-b-det)/(2*a);
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
2015-04-21
for x in [ 1,2,3,4,5,6,7,8,9]:
for y in [ 0,1,2,3,4,5,6,7,8,9]:
if x < y:
print x*10+y
for y in [ 0,1,2,3,4,5,6,7,8,9]:
if x < y:
print x*10+y
2015-04-21