import math
def quadratic_equation(a, b, c):
delt = b*b - 4*a*c
x1 = (-b + math.sqrt(delt))/2/a
x2 = (-b - math.sqrt(delt))/2/a
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
def quadratic_equation(a, b, c):
delt = b*b - 4*a*c
x1 = (-b + math.sqrt(delt))/2/a
x2 = (-b - math.sqrt(delt))/2/a
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
2015-04-17
def square_of_sum(L):
sum = 0
for i in L:
sum += i*i
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
sum = 0
for i in L:
sum += i*i
return sum
print square_of_sum([1, 2, 3, 4, 5])
print square_of_sum([-5, 0, 5, 15, 25])
2015-04-17
L = [75, 92, 59, 68]
sum = 0.0
for s in L:
sum = sum + s
print sum / 4
sum = 0.0
for s in L:
sum = sum + s
print sum / 4
2015-04-17
修改成这样也错。。。输出好像没有错
m = ('A','B')
t = ('a', 'b', m)
print t
m = ('A','B')
t = ('a', 'b', m)
print t
2015-04-16
sum = 0
x = 0
while x<100:
sum=sum+(2*x+1)
x=x+1
print sum
x = 0
while x<100:
sum=sum+(2*x+1)
x=x+1
print sum
2015-04-16
L = [95.5, 85, 59]
print L[-1]
print L[-2]
print L[-3]
print L[-4]
这样都能过,我也是醉了。。。。
print L[-1]
print L[-2]
print L[-3]
print L[-4]
这样都能过,我也是醉了。。。。
2015-04-16
print(45678+0x12fd2)
print("Learn Python in imooc")
print(100<99)
print(0xff==255)
print("Learn Python in imooc")
print(100<99)
print(0xff==255)
2015-04-16
L = ['Adam', 'Lisa', 'Paul', 'Bart']
L.pop(2)
L.pop()
print L
L.pop(2)
L.pop()
print L
2015-04-16
L = [95.5,85,59]
print L[0]
print L[1]
print L[2]
print L[2]
print L[0]
print L[1]
print L[2]
print L[2]
2015-04-15