d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for k, v in d.iteritems():
sum = sum + v
print k+":"+str(v)
print 'average', ':', sum/len(d)
sum = 0.0
for k, v in d.iteritems():
sum = sum + v
print k+":"+str(v)
print 'average', ':', sum/len(d)
2018-10-16
def average(*args):
sum = 0.0
if len(args) == 0:
return 0.0
else:
for n in args:
sum = sum + n
return sum/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
sum = 0.0
if len(args) == 0:
return 0.0
else:
for n in args:
sum = sum + n
return sum/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2018-10-16
如何理解汉诺塔的递归? - 酱紫君的回答 - 知乎
https://www.zhihu.com/question/24385418/answer/282940567
https://www.zhihu.com/question/24385418/answer/282940567
2018-10-15
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')
2018-10-15
print [a*100+b*10+c for a in range(1,10) for b in range(0,10) for c in range(1,10) if a == c]
2018-10-15
sum = 0
n = 1
while True:sum =sum + 2^n
n=n+1
if n >20:
break
print sum
麻烦过路的大神看一下问题出在了哪里。谢谢啦。
n = 1
while True:sum =sum + 2^n
n=n+1
if n >20:
break
print sum
麻烦过路的大神看一下问题出在了哪里。谢谢啦。
2018-10-14
s = set(['Adam', 'Lisa', 'Paul'])
全场最佳有木有异议
L = ['Adam', 'Lisa', 'Bart', 'Paul']
temp = set(L)
s = s ^ temp
print s
全场最佳有木有异议
L = ['Adam', 'Lisa', 'Bart', 'Paul']
temp = set(L)
s = s ^ temp
print s
2018-10-14
s = set(['Adam', 'Lisa', 'Bart', 'Paul'])
list = []
for name in s:
list.append(name.lower())
t = set(list)
s = s | t
print 'adam' in s
print 'bart' in s
list = []
for name in s:
list.append(name.lower())
t = set(list)
s = s | t
print 'adam' in s
print 'bart' in s
2018-10-14
d = {
95: 'Adam',
85: 'Lisa',
59: 'Bart',
}
if not d.get(72):
d[72] = 'Paul'
print d
95: 'Adam',
85: 'Lisa',
59: 'Bart',
}
if not d.get(72):
d[72] = 'Paul'
print d
2018-10-14
sum = 45678 + 0x12fd2
print(sum)
print("learn Python in imooc")
print(100 < 99)
print(0xff == 255)
print(sum)
print("learn Python in imooc")
print(100 < 99)
print(0xff == 255)
2018-10-13
print r'''"To be,or not to be":that is the question.\nWhether it's nobler in the mind to suffer.'''
2018-10-13