import math
def quadratic_equation(a, b, c):
x1 = (-b + math.sqrt(b*b-4*a*c))/2/a
x2 = (-b - math.sqrt(b*b-4*a*c))/2/a
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
def quadratic_equation(a, b, c):
x1 = (-b + math.sqrt(b*b-4*a*c))/2/a
x2 = (-b - math.sqrt(b*b-4*a*c))/2/a
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
2015-05-29
print r'''"To be, or not to be": that is the question.
Whether it's nobler in the mind to suffer.'''
Whether it's nobler in the mind to suffer.'''
2015-05-28
x1 = 1;
d = 3;
n = 100;
x100 =(x1 + d * (n-1)) ;
print (x100);
s = n*(x1 + x100)/2;
print s;
d = 3;
n = 100;
x100 =(x1 + d * (n-1)) ;
print (x100);
s = n*(x1 + x100)/2;
print s;
2015-05-28
print [x*100+y*10+z for x in range(1,10) for y in range(0,10) for z in range(0,10) if x==z]
2015-05-28
L = [95.5, 85, 59,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-05-27
sum = 0
x = 1
n = 1
while True:
sum=sum+x
x=pow(2,n)
n+=1
if n>20:
break
print sum
x = 1
n = 1
while True:
sum=sum+x
x=pow(2,n)
n+=1
if n>20:
break
print sum
2015-05-27
print [100 * m + 10 * n + q for m in range(1,10) for n in range(0, 10) for q in range(1, 10) if m == q]
2015-05-27
def toUppers(L):
return [x.upper() for x in L if type(x) == str]
print toUppers(['Hello', 'world', 101])
return [x.upper() for x in L if type(x) == str]
print toUppers(['Hello', 'world', 101])
print [int(m+n+m) for m in '123456789' for n in '0123456789']
2015-05-26
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for k, v in d.items():
sum += v
print k,' :',float(v)
print 'average', ':', sum/len(d)
sum = 0.0
for k, v in d.items():
sum += v
print k,' :',float(v)
print 'average', ':', sum/len(d)
2015-05-26
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for k, v in d.items():
sum = sum + v
print k,':',v
print 'average', ':', sum/len(d)
sum = 0.0
for k, v in d.items():
sum = sum + v
print k,':',v
print 'average', ':', sum/len(d)
2015-05-26
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for v in d.values():
sum+=v
print sum/len(d)
sum = 0.0
for v in d.values():
sum+=v
print sum/len(d)
2015-05-26