<jupyter_start><jupyter_text>SET 13  Structured Programming Using Python **DONE BY:THEJASWIN SRA1911026010029CSE-AIML**  1.**Write a Python program to sort a list of dictionaries using Lambda. Go to the editorOriginal list of dictionaries :[{'make': 'Nokia', 'model': 216, 'color': 'Black'}, {'make': 'Mi Max', 'model': '2', 'color': 'Gold'}, {'make': 'Samsung', 'model': 7, 'color': 'Blue'}]Sorting the List of dictionaries :[{'make': 'Nokia', 'model': 216, 'color': 'Black'}, {'make': 'Samsung', 'model': 7, 'color': 'Blue'}, {'make': 'Mi Max', 'model': '2', 'color': 'Gold'}]**<jupyter_code>models0029 = [{'make':'Nokia', 'model':216, 'color':'Black'}, {'make':'Mi Max', 'model':'2', 'color':'Gold'}, {'make':'Samsung', 'model': 7, 'color':'Blue'}]
print("\033[1mOriginal list of dictionaries :\033[0m")
print(models0029)
sorted_models0029 = sorted(models, key = lambda x: x['color'])
print("\n\033[1mSorting the List of dictionaries :\033[0m")
print(sorted_models0029)<jupyter_output>[1mOriginal list of dictionaries :[0m
[{'make': 'Nokia', 'model': 216, 'color': 'Black'}, {'make': 'Mi Max', 'model': '2', 'color': 'Gold'}, {'make': 'Samsung', 'model': 7, 'color': 'Blue'}]

[1mSorting the List of dictionaries :[0m
[{'make': 'Nokia', 'model': 216, 'color': 'Black'}, {'make': 'Samsung', 'model': 7, 'color': 'Blue'}, {'make': 'Mi Max', 'model': '2', 'color': 'Gold'}]<jupyter_text>2.**Create a Python function that accepts a string and calculate the number of upper caseletters and lower case letters. Sample String : 'The quick Brow Fox'Expected Output :No. of Upper case characters : 3No. of Lower case Characters : 12**<jupyter_code>def test0029(s):
    d={"UPPER_CASE":0, "LOWER_CASE":0}
    for c in s:
        if c.isupper():
           d["UPPER_CASE"]+=1
        elif c.islower():
           d["LOWER_CASE"]+=1
        else:
           pass
    print ("\033[1mOriginal String : \033[0m", s)
    print ("\033[1mNo. of Upper case characters : \033[0m", d["UPPER_CASE"])
    print ("\033[1mNo. of Lower case Characters : \033[0m", d["LOWER_CASE"])

s0029=input()
test0029(s0029)<jupyter_output>The quick Brow Fox
[1mOriginal String : [0m The quick Brow Fox
[1mNo. of Upper case characters : [0m 3
[1mNo. of Lower case Characters : [0m 12<jupyter_text>3.**Write a Python program to move all zero digits to end of a given list of numbers.Expected output:Original list:[3, 4, 0, 0, 0, 6, 2, 0, 6, 7, 6, 0, 0, 0, 9, 10, 7, 4, 4, 5, 3, 0, 0, 2, 9, 7, 1]Move all zero digits to end of the said list of numbers:[3, 4, 6, 2, 6, 7, 6, 9, 10, 7, 4, 4, 5, 3, 2, 9, 7, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]**<jupyter_code>def zerotoend0029(arr,n):
    count=0
    for i in range(n):
        if arr[i]!=0:
            arr[count]=arr[i]
            count+=1
    while(count<n):
        arr[count]=0
        count+=1

arr0029=[3, 4, 0, 0, 0, 6, 2, 0, 6, 7, 6, 0, 0, 0, 9, 10, 7, 4, 4, 5, 3, 0, 0, 2, 9, 7, 1]
print("\033[1mOriginal list: \033[0m")
print(arr0029)
n = len(arr0029) 
zerotoend0029(arr0029, n) 
print("\033[1mMove all zero digits to end of the said list of numbers: \033[0m") 
print(arr0029)<jupyter_output>[1mOriginal list: [0m
[3, 4, 0, 0, 0, 6, 2, 0, 6, 7, 6, 0, 0, 0, 9, 10, 7, 4, 4, 5, 3, 0, 0, 2, 9, 7, 1]
[1mMove all zero digits to end of the said list of numbers: [0m
[3, 4, 6, 2, 6, 7, 6, 9, 10, 7, 4, 4, 5, 3, 2, 9, 7, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]<jupyter_text>4.**Create a Python script to print a dictionary where the keys are numbers between 1 and15 (both included) and the values are square of keys.Sample Dictionary{1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81, 10: 100, 11: 121, 12: 144, 13: 169,14: 196, 15: 225}**<jupyter_code>d0029={}
for i in range(1,16):
    d0029[i]=i**2
print(d0029)<jupyter_output>{1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81, 10: 100, 11: 121, 12: 144, 13: 169, 14: 196, 15: 225}<jupyter_text>5.**Write a Python program to find the numbers of a given string and store them in a list,display the numbers which are bigger than the length of the list in sorted form. Uselambda function to solve the problem. Original string: sdf 23 safs8 5 sdfsd8 sdfs 56 21sfs 20 5Numbers in sorted form:20 23 56**<jupyter_code>str0029 = "sdf 23 safs8 5 sdfsd8 sdfs 56 21sfs 20 5"
print("\033[1mOriginal string: \033[0m",str0029)
str_num=list(str0029.split(' '))
leng=len(str_num)
numbers=sorted([int(x) for x in str_num if x.isdigit()])
print('\033[1mNumbers in sorted form: \033[0m')
for y in filter(lambda x:x>leng,numbers):
    print(y,end=' ')<jupyter_output>[1mOriginal string: [0m sdf 23 safs8 5 sdfsd8 sdfs 56 21sfs 20 5
[1mNumbers in sorted form: [0m
20 23 56
{'fraction_non_alphanumeric': 0.1858159086009916, 'fraction_numerical': 0.11575770640224187, 'mean_word_length': 4.376593279258401, 'pattern_counts': {'":': 2, '<': 17, '<?xml version=': 0, '>': 17, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '226226', 'license': 'MIT', 'n_tokens_mistral': 2277, 'n_tokens_neox': 1804, 'n_words': 645, 'path': 'WEEK-2.ipynb', 'repo_name': 'thejaswin123/APP_lab', 'size': '4639'}