s = 'Python was started in 1989 by "Guido". \n Python is free and easy to learn.'
print s
print s
2016-02-23
x1 = 1
d = 3
n = 100
x100 = x1+n*d
s = n*x1+n*(n-1)*d/2
print s
d = 3
n = 100
x100 = x1+n*d
s = n*x1+n*(n-1)*d/2
print s
2016-02-23
sum = 0
x = 1
while x<100 && x%2==1:
sum+=x
print sum
x = 1
while x<100 && x%2==1:
sum+=x
print sum
2016-02-23
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.'''
2016-02-23
s = 'Python was started in 1989 by \"Guido\".\t\nPython is free and easy to learn.'
print s
print s
2016-02-23
x1 = 1
d = 3
n = 100
xn = x1 + (n-1)*d
s = (x1+xn)*n/2
print xn
print s
d = 3
n = 100
xn = x1 + (n-1)*d
s = (x1+xn)*n/2
print xn
print s
2016-02-23
L = [1]
n=1
while n<100:
L.insert(n,(n+1)*(n+1))
n=n+1
print sum(L)
n=1
while n<100:
L.insert(n,(n+1)*(n+1))
n=n+1
print sum(L)
2016-02-23
def move(n, a, b, c):
if n==1:
print a,'-->',c
else:
print a,'-->',b
move(n-1,a,b,c)
print b,'-->',c
return
move(4, 'A', 'B', 'C')
我认为应该是这样写的
输出:
A --> B
A --> B
A --> B
A --> C
B --> C
B --> C
B --> C
if n==1:
print a,'-->',c
else:
print a,'-->',b
move(n-1,a,b,c)
print b,'-->',c
return
move(4, 'A', 'B', 'C')
我认为应该是这样写的
输出:
A --> B
A --> B
A --> B
A --> C
B --> C
B --> C
B --> C
2016-02-22
def move(n, a, b, c):
if n==2:
print a,'-->',b
print a,'-->',c
print b,'-->',c
if n>2:
move(n-1, a, c, b)
print a,'-->',c
move(n-1, b, a, c)
move(4, 'A', 'B', 'C')
看了大家的发现自己的是按照他叙述写的。。。。我写的好麻烦。。。
if n==2:
print a,'-->',b
print a,'-->',c
print b,'-->',c
if n>2:
move(n-1, a, c, b)
print a,'-->',c
move(n-1, b, a, c)
move(4, 'A', 'B', 'C')
看了大家的发现自己的是按照他叙述写的。。。。我写的好麻烦。。。
2016-02-22