sum = 0
x = 1
n = 1
while True:
sum+=x
x=x*2
if x>2**19:
break
print sum
x = 1
n = 1
while True:
sum+=x
x=x*2
if x>2**19:
break
print sum
2015-05-16
s = set([('Adam', 95), ('Lisa', 85), ('Bart', 59)])
for x in s:
print '%s:%s'%(x[0],x[1])
for x in s:
print '%s:%s'%(x[0],x[1])
2015-05-16
import math
def quadratic_equation(a, b, c):
temp = b*b - 4*a*c
temp = math.sqrt(temp)
x1 = (-b + temp)/(2*a)
x2 = (-b - temp)/(2*a)
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
多美的代码
def quadratic_equation(a, b, c):
temp = b*b - 4*a*c
temp = math.sqrt(temp)
x1 = (-b + temp)/(2*a)
x2 = (-b - temp)/(2*a)
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
多美的代码
2015-05-14