最新回答 / DanDanHang
<...code...>自己解讀下這句話,應該對你有幫助 If initial is present, it is placed before the items?of the sequence in the calculation, and serves as a default when the?sequence is empty.?
2015-04-07
最贊回答 / a412739861
不是,Fib(n)中的n其實匹配的是for n in range(num)中的num,進行了num次迭代。循環是為了構成n個斐波那契數列,你把for n in的n換成x也是可以的。
2015-04-05
最新回答 / DanDanHang
是的,注意底下加粗的部分Help on built-in function reduce in module __builtin__:reduce(...)? ? reduce(function, sequence[, initial]) -> value? ? Apply a function of two arguments cumulatively to the items of a sequence,? ? from left to right, so as to reduce the se...
2015-04-05
最贊回答 / lhclylzl
當含有其他類是,可以判斷其他類的類型。例如有數字和字符串,數字和分數比較,字符串和名字比較 ??? def __cmp__(self, s):??????? if isinstance(s,Student):??????????? if self.score<s.score:??????????????? return -1??????????? elif self.score>s.score:??????????????? return 1??????????? else:?????????...
2015-04-05