print [int(str(x)+str(y)+str(x)) for x in range(1,10) for y in range(10) ]
我觉得这样写简单些啊
我觉得这样写简单些啊
2015-11-10
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-11-10
L = [95.5,85,59]
print L[0]
print L[1]
print L[2]
print L
Z正确答案
print L[0]
print L[1]
print L[2]
print L
Z正确答案
2015-11-10
>>> L[1:3]
['Adam', 'Lisa']
这个错了
应该是这样的 结果:
>>> L[1:3]
['Lisa', 'Bart']
['Adam', 'Lisa']
这个错了
应该是这样的 结果:
>>> L[1:3]
['Lisa', 'Bart']
2015-11-09
def move(n, a, b, c):
if n==1:
print a,'-->',c
else:
move(n-1,a,c,b)
move(1,a,b,c)
move(n-1,b,a,c)
move(4, 'A', 'B', 'C')
if n==1:
print a,'-->',c
else:
move(n-1,a,c,b)
move(1,a,b,c)
move(n-1,b,a,c)
move(4, 'A', 'B', 'C')
2015-11-08
import math
def quadratic_equation(a, b, c):
delta=b*b-4*a*c
if (delta)<0:
print 'No Solution!'
else:
x1=(-b+math.sqrt(delta))/(2*a)
x2=(-b-math.sqrt(delta))/(2*a)
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
def quadratic_equation(a, b, c):
delta=b*b-4*a*c
if (delta)<0:
print 'No Solution!'
else:
x1=(-b+math.sqrt(delta))/(2*a)
x2=(-b-math.sqrt(delta))/(2*a)
return x1,x2
print quadratic_equation(2, 3, 0)
print quadratic_equation(1, -6, 5)
2015-11-08