已采纳回答 / rubyc
你这是递归思想还没有形成,主要问题不在于return,函数体中遇到return函数就结束了,之所以调用很多次是因为递归的原因,return的位置取决于你想让它在函数体中什么情况下结束。
2016-09-25
感觉好懵,这个程序我在python上试过没有return也可以,但是原来例子上的就不能没有return,好奇怪,感觉思维跟不上。。
2016-09-25
tds = [generate_tr(d) for name, score in d.iteritems()]
print '<table border="1">'
if Score < 60:
print '<tr><th>Name</th><th><td style="color:red">Score</th><tr>'
else:
print '<tr><th>Name</th><th>Score</th><tr>'
print '\n'.join(tds)
print '</table>'
print '<table border="1">'
if Score < 60:
print '<tr><th>Name</th><th><td style="color:red">Score</th><tr>'
else:
print '<tr><th>Name</th><th>Score</th><tr>'
print '\n'.join(tds)
print '</table>'
2016-09-25
d = { 'Adam': 95, 'Lisa': 85, 'Bart': 59, 'Paul': 74 }
sum = 0.0
for 想 in d.values():
sum+=想
print sum/len(d)
你们觉得这样可以么,哈哈
sum = 0.0
for 想 in d.values():
sum+=想
print sum/len(d)
你们觉得这样可以么,哈哈
2016-09-25
score = 55
if score>=60:
print 'passed'
else:
print 'failed'
if score>=60:
print 'passed'
else:
print 'failed'
2016-09-25
L = ['Adam', 'Lisa', 'Bart']
L.insert(0,L.pop())
L.insert(1,L.pop(-1))
print L
L.insert(0,L.pop())
L.insert(1,L.pop(-1))
print L
2016-09-25
for x in [ '1','2','3','4','5','6','7','8','9' ]:
for y in [ '1','2','3','4','5','6','7','8','9' ]:
if x < y :
print x + y
for y in [ '1','2','3','4','5','6','7','8','9' ]:
if x < y :
print x + y
2016-09-25