def move(n, a, b, c):
if n==1:
print a,'-->',c
else:
move(n-1,a,c,b)
print a,'-->',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)
print a,'-->',c
move(n-1,b,a,c)
move(4, 'A', 'B', 'C')
2015-10-02
python解释执行 运行速度慢但是代码量少
C编译为机器码运行速度非常快 代码量非常多
Java编译为字节码运行速度快,代码量多
C编译为机器码运行速度非常快 代码量非常多
Java编译为字节码运行速度快,代码量多
2015-10-02
L = [75, 92, 59, 68]
sum = 0.0
for score in L:
sum=sum+score
print sum / 4
sum = 0.0
for score in L:
sum=sum+score
print sum / 4
2015-10-01
score = 55
if score>=60:
print 'passed'
else:
print 'failed'
if score>=60:
print 'passed'
else:
print 'failed'
2015-10-01
for x in range(1,10):
for y in range(1,10):
if x< y:
print str(x)+str(y)
for y in range(1,10):
if x< y:
print str(x)+str(y)
2015-10-01
def firstCharUpper(s):
return s.upper()[:1]+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
return s.upper()[:1]+s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')
2015-09-30