Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View msamoylov's full-sized avatar

Michael Samoylov msamoylov

View GitHub Profile
msamoylov / gist:07026636872c93331400
Last active August 29, 2015 14:15
Python screening questions
def powers():
return [lambda x : x ** i for i in range(3)]
print [m(5) for m in powers()] # Produces [25, 25, 25]
# What would you change to get the expected [1, 5, 25] results?
def powers():
for i in range(3): yield lambda x : x ** i
print [m(5) for m in powers()]