Skip to content

Instantly share code, notes, and snippets.

@theSamyak
Created June 17, 2024 12:40
Show Gist options
  • Save theSamyak/d2a3999e45b473d3adafa11e69407b3f to your computer and use it in GitHub Desktop.
Save theSamyak/d2a3999e45b473d3adafa11e69407b3f to your computer and use it in GitHub Desktop.
Example: Creating Multiplier Functions with Lambdas
def create_multiplier(factor):
return lambda x: x * factor
# Create specific multiplier functions
double = create_multiplier(2)
triple = create_multiplier(3)
# Use the created functions
print(double(5)) # Output: 10
print(triple(5)) # Output: 15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment