Question: Question 5 (1 points) The following code arbeast de tupled up wing the destructuplex theatly. As her in the code, this is done by setting


Question 5 (1 points) The following code arbeast de tupled up wing the destructuplex theatly. As her in the code, this is done by setting the art key of the ortad() functionalabdis function, which take an input argument named and new [+] cendent of 2). teps - Ingla', ). ("Science", 90), ('athe, 9), ('atory'. sz)] rewalt - orted(tupa, key - labda : [1] print(lt) The above code output the Swing (ted list of tupil) to the conce [CHistory'. 12). (English', sa), ("Science", 90). (Mathe, 97)] No write a functies that morta a list of dictici Sollow Create a functions mart_by_melected_kay with two positional arged dicta and kes. The function will allow to chce which kimg the positional argumynas) to e fiting the input list of dictionaris given by the partial argument dicta . Seet the list of dietaris dicta by the lary kayano in coding arder. Accomplish this by long the ortad() function with its argument kay talambda function. This lambda function should take a dictionary as its inpat gammt and return the value for the Lory kay from the input dictionary this will be it to the land function in the above cumple code with the list of tupla . Ut factice return statement to provide the newly red list of dictionaries to the function caller and your functies will not proceed any furth. Correct Check If yes www to run the following functie call your catprat erald be wollen: la liat of dictionaria esploys tame': Juha! 31, 'y' 2.9)] >>- mort_by_elected_key(esployees, m') .arting by name >>>print() [C': 'la', 'age: 31. '': 2.0). >> D-mart_by_elected wysployees, '').wording by age >> prit() C'e': 'Lia', 'age":34. sz: 3.1). '': 25. '': 2.5). >>- mart_by_elected_key(employees, "yara') aorting by years '': 25. '': 2.5). ar: 34. 3.1) Question 6 (1 points) Write a generator function that gets and integere that are between 1 and 2). For this, we will the raadist function from the randce package in order to generate a random integer Search for the documentation of the randant functies from the random poudag. The write a brief descriptive of the radiat() function as the comments. Your docription et contain (1) what raadindow (2) tax of radiat() and (3) what are the arguments indicate saimed or optional) and what they do. Start code sport random (WRITE YOUR DESGLIPTION OF Trandint() FUNCTION FOR THE random PCG) Place your code below this tine ar Place your code above the line DERENCE TI yeld AND retur Bund on the starter code show you need to do the following Create a function and lottery that he come laryward armastused with a default value of 6. The value of this keywed guests will be the totalmber of random smbers to mate Imide your name function, sea for beptatement that loopen times (you can use the range fractice) and do the following at each iteration Line therandant() function to rate and sumber between 1 and (induading both 1 and a) and return it wigyele statement tead of a return statements that your function becomes a yemmator function. In your wanda, bei decribe 2-3 hore gratefactice that yield staat in different compared to a regular function that a return statement. Write your awer Python Correct Check If yus we to run the following functie calls, your crat prutald be follows: C! NOTE: Actual sumber printed crat to the cake will be different and time you run your function ence the numbers are rundenly grated) >> 8 - lottery(2) >>> prist(type(s) ) clae gerator> 12 >>> prit(x) 35 >>. list(lottary) generatua randon numbers between I and to (ZT. 32. 11, 8, 740) >> tuple(lattery (-10)).generater 20 random number between 1 and 40 (4, 12, 30, 1, 22, 20, 13, 25, 35, 39) >> for 1 ia lottery(4): print('Handian sumber'. :) Random number: 19 Random susber: 7 Randomsumber 31
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
