Aan de slagGa gratis aan de slag

Lazy evaluation

When Python is working its way through the following script, which line will it get to when the 'Converting to percentage' message is printed?

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)

You can use the console to help you figure out the answer. The fraction_to_percent() function is already available in the session.

Deze oefening maakt deel uit van de cursus

Parallel Programming with Dask in Python

Cursus bekijken

Praktische interactieve oefening

Zet theorie om in actie met een van onze interactieve oefeningen.

Begin met trainen