<jupyter_start><jupyter_text>Lambda Expressions, Map and Filter<jupyter_code>def cube(num):
    return num**3
cube(2)
my_num = [1,2,3,4,5,6,7,8,9,10]<jupyter_output><empty_output><jupyter_text>Problem is to pass each every item in the list to the function cube as argument and store the results in a new list<jupyter_code>my_result= []
for num in my_num:
    my_result.append(cube(num))
print(my_result)
list(map(cube,my_num))<jupyter_output><empty_output><jupyter_text>Filter<jupyter_code>def check_even(num):
    return num%2==0
check_even(4)
check_even(5)
my_num<jupyter_output><empty_output><jupyter_text>Problem is to filter out all the objects which are satisfying the particular case in given function and if the result is true add the result in new list<jupyter_code>even_list = []
for num in my_num:
    if check_even(num):
       even_list.append(num)
print (even_list)
list(filter(check_even,my_num))<jupyter_output><empty_output><jupyter_text>Lambda Expressions<jupyter_code>def square(num):
    result=num**2
    return result
square(2)
def square(num):
    return num**2
def square(num): return num**2<jupyter_output><empty_output><jupyter_text>Problem is for small scale function in which I want to run a single line expression that too by keeping in mind the design sense of overall program and minimizing no of line of code and even for defining functions in a single line ad-hoc manner<jupyter_code>sqr = lambda num: num ** 2
sqr(5)
def check_odd(num):
    result = num%2 != 0
    return result
check_odd(5)
my_new_odd_num = list(filter(lambda num : num%2!=0,my_num))
my_new_odd_num
marks = [45,67,89,56,98,82,32,74,68,59,90,73]
top_marks = list(filter(lambda num : num > 85,marks))
print(top_marks)
print(len(top_marks))
marks = [45,67,89,56,98,82,32,74,68,59,90,73]
Grade_A = list(filter(lambda num : 90 >= num <= 85,marks))
marks = [45,67,89,56,98,82,32,74,68,59,90,73]
def grade(mark):
    if (mark >= 90):
        return 'A'
    elif (mark >= 80):
        return 'B'
    elif (mark >= 70):
        return 'C'
    elif (mark >= 60):
        return 'D'
    elif (mark >= 50):
        return ('E')
    elif (mark > 0):
        return 'Fail'
result = list(map(grade,marks))
result<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12382234185733512, 'fraction_numerical': 0.052489905787348586, 'mean_word_length': 5.177285318559557, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 33, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '466664', 'license': 'MIT', 'n_tokens_mistral': 880, 'n_tokens_neox': 815, 'n_words': 216, 'path': 'Lambda Expressions.ipynb', 'repo_name': 'hassim3010/Python_FCS_Batch3', 'size': '2229'}