19 solutions available
Question 5Which of the following is the correct expansion of list_1 = [expr(i) for i in list_0 if func(i)] ?(a)list_1 = [] for i in list_0: if...
Question 16How are lists internally stored ? How are 2D lists internally stored ?
Question 1Create a list SqLst that stores the doubles of elements of another list NumLst. Following code is trying to achieve this. Will this code...
Question 2Change the above code so that it works as stated in previous question.
Question 3Modify your previous code so that SqLst stores the doubled numbers in ascending order.
Question 4Consider a list ML = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]. Write code using a list comprehension that takes the list ML and makes a new...
Question 6Write equivalent for loop for the following list comprehension :gen = (i/2 for i in [0, 9, 21, 32]) print(gen)
Question 7Predict the output of following code if the input is :(i) 12, 3, 4, 5, 7, 12, 8, 23, 12(ii) 8, 9, 2, 3, 7, 8Code :s = eval(input("Enter a...
Question 8Predict the output :def h_t(NLst): from_back = NLst.pop() from_front = NLst.pop(0)...
Question 9Predict the output :ages = [11, 14, 15, 17, 13, 18, 25] print(ages) Elig = [x for x in ages if x in range(14, 18)] print(Elig)
Question 10Predict the output :L1= [x ** 2 for x in range(10) if x % 3 == 0] L2 = L1 L1.append(len(L1)) print(L1) print(L2)...
Question 11Predict the output :def even(n): return n % 2 == 0 list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9] ev = [n for n in list1 if n % 2 == 0] evp = [n...
Question 12(i)Predict the output.b = [[9, 6], [4, 5], [7, 7]] x = b[:2] x.append(10) print(x)
Question 12(ii)Predict the output.b = [[9, 6], [4, 5], [7, 7]] x = b[:2] x[1].append(10) print(x)
Question 13Find the Error. Consider the following code, which runs correctly at times but gives error at other times. Find the error and its...
Question 14Suggest the correction for the error(s) in previous question's code.
Question 15(ii)Find the error. Consider the following code and predict the error(s):(y for y in range(100) if y % 2 == 0 and if y % 5 == 0)
Question 16Find the error in the following list comprehension :["good" if i < 3: else: "better" for i in range(6)]
Question 17Suggest corrections for the errors in both the previous questions.