<jupyter_start><jupyter_text>0. Функции<jupyter_code>def funsum(sequence, f):
    sum = 0
    for value in sequence:
        sum += f(value)
    return sum

def maxfun(sequence, func, *functions):
    max_sum = funsum(sequence, func)
    max_func = func
    for f in functions:
        sum = funsum(sequence, f)
        if sum >= max_sum:
            max_sum = sum
            max_func = f
    return max_func
def f(*a, **b):
  print(*a, b)

f(10, 11, 12, 13, a=10, b=11, c=12, d=14)
def maxfun(sequence, *functions):
    return max(functions[::-1], key=lambda f: sum(f(i) for i in sequence))

from math import sin, cos
def comparator(x):
  return int(x)

max([1, '5', 3, 4], key=lambda x: int(x))
input_list = [[1], [2, 3, 4], [5, 6, 7], [1]]
output_list = sorted(item for sublist in input_list for item in sublist)
output_list
def plus(a, b):
  return a + b

print(plus)
plus
def print_locals(a, b):
  print(globals())
print_locals(1, 2)
# func_name = input()
# globals()[func_name](1, 2)
locals()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15354713313896987, 'fraction_numerical': 0.034013605442176874, 'mean_word_length': 3.517543859649123, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '632299', 'license': 'MIT', 'n_tokens_mistral': 424, 'n_tokens_neox': 404, 'n_words': 119, 'path': 'WS03-functions.ipynb', 'repo_name': 'PersDep/python-intro-2021', 'size': '1029'}