Skip to content

Instantly share code, notes, and snippets.

View bee-san's full-sized avatar
🌻
Tending to my plants

Autumn (Bee) bee-san

🌻
Tending to my plants
View GitHub Profile
x = range(-5, 5)
all_less_than_zero = [num * num for num in x if num < 0]
x = range(-5, 5)
all_less_than_zero = list(map(lambda num: num * num, list(filter(lambda num: num < 0, x))))
x = range(-5, 5)
all_less_than_zero = [num for num in x if num < 0]
x = range(-5, 5)
all_less_than_zero = list(filter(lambda num: num < 0, x))
print(all_less_than_zero)
print([x * x for x in [1, 2, 3, 4]])
[function for item in iterable]
foo = lambda a: 2
def foo(a):
return 2
from functools import partial
powers = []
for x in range(2, 1001):
powers.append(partial(power, exponent = x))
print(powers[0](3))
# output is 9
from functools import partial
square = partial(power, exponent=2)
print(square(2))
# output is 4
def square(base):
return power(base, 2)