延遲評估
當 Python 依序執行以下指令稿時,當印出訊息「'Converting to percentage'」時,會跑到哪一行?
from dask import delayed
def fraction_to_percent(x):
percentage = x * 100
print('Converting to percentage')
return x
frac = 0.3
percentage = delayed(fraction_to_percent)(frac)
computed_percentage = percentage.compute()
print(percentage)
print(computed_percentage)
你可以使用主控台來協助找出答案。工作階段中已經提供 fraction_to_percent() 函式。
本練習屬於課程
