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
def power(base, exponent):
return base ** exponent
def rtnBrandon():
return "brandon"
def rtnJohn():
return "john"
def rtnPerson():
age = int(input("What's your age?"))
if age == 21:
return rtnBrandon()
def summation(nums):
return sum(nums)
def action(func, numbers):
return func(numbers)
print(action(summation, [1, 2, 3]))
# Output is 6
x = range(-5, 5)
all_less_than_zero = list(filter(lambda num: num < 0, x))
x = range(-5, 5)
new_list = []
for num in x:
if num < 0:
new_list.append(num)
filter(function, list)
from functools import reduce
product = reduce((lambda x, y: x * y),[1, 2, 3, 4])
product = 1
x = [1, 2, 3, 4]
for num in x:
product = product * num
reduce(function, list)
x = [1, 2, 3, 4, 5]
print(list(map(lambda num: num * num, x)))