Lab 3: Recursion, Tree Recursion(CS61A 2020)
在网上没有lab3相应的答案,作者也卡蛮久
(就此补充一下答案)
Q2: WWPD: Journey to the Center of the Earth
Use Ok to test your knowledge with the following "What Would Python Display?" questions:
python3 ok -q sr-wwpd -u
For all WWPD questions, type
Function
if you believe the answer is<function...>
,Error
if it errors, andNothing
if nothing is displayed.
>>> def crust():
... print("70km")
... def mantle():
... print("2900km")
... def core():
... print("5300km")
... return mantle()
... return core
... return mantle
>>> drill = crust
>>> drill = drill()
>>70km
>>> drill = drill()
>>2900km
>>> drill = drill()
>>5300km
>>2900km
>>> drill()
>>5300km
>>2900km
>>Function