【发布时间】:2011-02-20 21:13:44
【问题描述】:
当a为6时,循环体末尾的i的值是多少?
def loopIdentification():
i=0
for a in range(2,8):
i=i+a-3
return i
【问题讨论】:
-
你为什么不试试那个代码并调用那个函数呢?
标签: python python-2.6
当a为6时,循环体末尾的i的值是多少?
def loopIdentification():
i=0
for a in range(2,8):
i=i+a-3
return i
【问题讨论】:
标签: python python-2.6
5
>>> def loopIdentification():
i=0
for a in range(2,8):
i=i+a-3
print a, i
return i
>>> loopIdentification()
2 -1
3 -1
4 0
5 2
6 5
7 9
9
【讨论】: