Question: please follow the instructions , using phython Homework Presentation & Submission: * You must attempt only the first two problems (A & B), while the






please follow the instructions , using phython
Homework Presentation \& Submission: * You must attempt only the first two problems (A \& B), while the others (C&D) are for practice purposes. * Provide the output solution for each sub-problem (part). Otherwise, 50% marks will be deducted. * Every sub-problem (part) should be answered on a DIFFERENT CELL as given in the template. * EVERY CELL should have a problem and part number clearly written in the first line. * All cells of your homework should be in CHRONOLOGICAL order. One cell per sub-problem. * Any text should be written as a comment in the code cell. Do NOT modify the code cell into the markdown cell. * Submit the entire homework as ONE single .ipynb document. * Do NOT add/delete any cell in the given template. Problem A [50 Marks]: Solve the following questions using python only. A-1. Create a list L1 containing numbers from 15 to 24 (24 exclusive), using LIST COMPREHENSION (do not use list function or usual FOR loop). Sort the list in ascending order. Create a new list L2 from L1 using LIST COMPREHENSION, where the elements of L1 and L2 are related as follows: L2=[] for i, e in enumerate (L1) : if e%2==1: if e>i: L2. append (e+i) else: L2. append(ei) A-2. Let B=[61,25,36,21,58,101,254,200] be a list. Apply the following function (x2 (x2))//50 on each element of B. Don't use FOR loop! A-2. Let B=[61,25,36,21,58,101,254,200] be a list. Apply the following function (x2 (x2))//50 on each element of B. Don't use FOR loop! (4 marks) A-3. Consider the following text: "dvoxlnv gl rhv 291 rg droo yv z ivzoob rmgvivhgrmt xlfihv, wl blfi yvhg zmw ivnvnyvi gszg mlgsrmt yvggvi gszm gsv sziw dlip." a. Create a list of words (all contiguous characters) in the order of their appearance. Remove newline characters (if any) from the list. Consider the following texts: Text1 = "dvoxlnv gl rhv 291 rg droo yv z ivzoob rmgvivhgrmt xlfihv, wl blfi yvhg zmw ivnvnyvi gszg mlgsrmt yvggvi gszm gsv sziw dlip , gsv xlfihv xlmgzrm 4 slnvdliph" Text 2= "welcome to ise 291 it will be a really interesting course, do your best and remember that nothing better than the hard work, the course contain 4 homeworks" a. Create a dictionary where words (all contiguous characters) from Text1 are keys, and words from Text 2 are values. b. Is there any difference in the total number of words in Text1 and the total number of keys in the above dictionary? If yes, then explain the reason for the difference. (10 marks) A-5. A-5: Create a random integer numpy two-dimensional array of size 59, where the integer values range from 1 to 100 (100 inclusive). Set the random generator seed to be 26 . Call the array as S. Print the dimensions, shape, and size of S. A-6. Print alternate columns starting from column indexed 3 and all the rows of S. (4 marks) (3 marks) A-7. Create a new numpy array M1 that contains third-row elements of S in order of column 8, then 5, then 3, then 1. Similarly, create a new array M2 that contains fourth-row elements in order of column 9 , then column 7 , then column 2 , then 8 . A-6. Print alternate columns starting from column indexed 3 and all the rows of S. (3 marks) A-7. Create a new numpy array M1 that contains third-row elements of S in order of column 8, then 5, then 3, then 1. Similarly, create a new array M2 that contains fourth-row elements in order of column 9 , then column 7 , then column 2 , then 8. (4 marks) A-8. Create a new one-dimensional array by joining M1 and M2. Create another new two-dimensional array by vertically joining M2 below M1. (4 marks) A-9. Create a copy of S, say P. Sort the elements in the even columns of P (that is, in each even column, the smallest element is in the first row, and the largest in the last row). Print both S and P. (4 marks) A-10. Add the following array [1,2,3,4,5,6,7,8,9] to all the rows of P. Print all the elements of updated P that are strictly between 20 and 60 . (4 marks)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
