<jupyter_start><jupyter_text>1 Write a Python Program to implement your own myreduce() function which works exactly  like Python's built-in function reduce()<jupyter_code>def myreduce(func, iterable):
    """
    myreduce function is a user-built function version of Python built-in function reduce()
    func : takes the function which needs to be applied on the iterable
    iterable : list or any iterable object on which cumulative calculation can be performed  
    """
    it = iter(iterable)
    result = next(it)
    for element in it:
        result = func(result, element)
    return result
import functools

l = [1,2,3,4,5]

print(functools.reduce(lambda a, b: a+b, l))
print(myreduce(lambda a, b: a+b, l))<jupyter_output>15
15<jupyter_text>2 Write a Python program to implement your own myfilter() function which works exactly  like Python's built-in function filter()<jupyter_code>def myfilter(func, iterable):
    """
    myfilter function is a user-built function version of Python built-in function filter()
    func : takes the function which needs to be applied on the iterable
    iterable : list or any iterable object on which cumulative calculation can be performed  
    """
    result = []
    for i in iterable:
        if func(i):
            result.append(i)
    return result
seq = [0, 1, 2, 3, 5, 8, 13]
  
print(list(filter(lambda x: x % 2 != 0, seq)))
print(myfilter(lambda x: x % 2 != 0, seq))<jupyter_output>[1, 3, 5, 13]
[1, 3, 5, 13]<jupyter_text>2. Implement List comprehensions to produce the following lists.  Write List comprehensions to produce the following Lists :['A', 'C', 'A', 'D', 'G', 'I', ’L’, ‘ D’] ['x', 'xx', 'xxx', 'xxxx', 'y', 'yy', 'yyy', 'yyyy', 'z', 'zz', 'zzz', 'zzzz'] ['x', 'y', 'z', 'xx', 'yy', 'zz', 'xxx', 'yyy', 'zzz', 'xxxx', 'yyyy', 'zzzz'] [[2], [3], [4], [3], [4], [5], [4], [5], [6]][[2, 3, 4, 5], [3, 4, 5, 6],  [4, 5, 6, 7], [5, 6, 7, 8]] [(1, 1), (2, 1), (3, 1), (1, 2), (2, 2), (3, 2), (1, 3), (2, 3), (3, 3)]<jupyter_code>str1 = "ACADGILD"
str_list = [i for i in str1]
print(str_list)
str2 = ['x','y','z']
str_list = [i*n for i in str2 for n in range(1,5)]
print(str_list)
num_list = [2, 3, 4]
numsum_list = [[i+n] for i in num_list for n in range(0,3)]
print(numsum_list)
num_list = [2, 3, 4, 5]
numsum_list = [[i+n for i in num_list] for n in range(0,4)]
print(numsum_list)
pair_list = [1, 2, 3]
pairresult_list = [(b, a) for a in pair_list for b in pair_list]
print(pairresult_list)<jupyter_output>[(1, 1), (2, 1), (3, 1), (1, 2), (2, 2), (3, 2), (1, 3), (2, 3), (3, 3)]
{'fraction_non_alphanumeric': 0.17714061272584447, 'fraction_numerical': 0.045168892380204245, 'mean_word_length': 4.053571428571429, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '494760', 'license': 'Apache-2.0', 'n_tokens_mistral': 1034, 'n_tokens_neox': 964, 'n_words': 355, 'path': 'Python Assignment - 3.ipynb', 'repo_name': 'aarohisnh/Assignment', 'size': '2546'}