Skip to content

Instantly share code, notes, and snippets.

@msamoylov
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msamoylov/07026636872c93331400 to your computer and use it in GitHub Desktop.
Save msamoylov/07026636872c93331400 to your computer and use it in GitHub Desktop.
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()]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment