On This Page

This set of Python Programming Multiple Choice Questions & Answers (MCQs) focuses on Python Programming Set 2

Q1 | What is the output of the following program?L = [1, 3, 5, 7, 9]print(L.pop(-3), end = ' ')print(L.remove(L[0]), end = ' ')print(L)
Q2 | What is the output of the following program?def REVERSE(L):L.reverse()return(L)def YKNJS(L):List = list()List.extend(REVERSE(L))print(List)L = [1, 3.1, 5.31, 7.531]YKNJS(L)
Q3 | What is the output of the following program?from math import sqrtL1 = [x**2 for x in range(10)].pop()L1 + = 19print(sqrt(L1), end = " ")L1 = [x**2 for x in reversed(range(10))].pop()L1 + = 16print(int(sqrt(L1)))
Q4 | What is the output of the following program?D = dict()for x in enumerate(range(2)):D[x[0]] = x[1]D[x[1]+7] = x[0]print(D)
Q5 | What is the output of the following program?D = {1 : 1, 2 : '2', '1' : 1, '2' : 3}D['1'] = 2print(D[D[D[str(D[1])]]])
Q6 | What is the output of the following program?D = dict()for i in range (3):for j in range(2):D[i] = jprint(D)
Q7 | What is the output of the following program? from math import *a = 2.13b = 3.7777c = -3.12print(int(a), floor(b), ceil(c), fabs(c))
Q8 | What is the output of the following program?
Q9 | What is the output of the following program?import stringimport stringLine1 = "And Then There Were None"Line2 = "Famous In Love"Line3 = "Famous Were The Kol And Klaus"Line4 = Line1 + Line2 + Line3print(string.find(Line1, 'Were'), string.count((Line4), 'And'))
Q10 | What is the output of the following program?line = "What will have so will"L = line.split('a')for i in L:print(i, end=' ')
Q11 | What is the type of each element in sys.argv?
Q12 | What is the length of sys.argv?
Q13 | What is the output of the following code?def foo(k):k[0] = 1q = [0]foo(q)print(q)
Q14 | What is the output of the following code?def foo(fname, val):print(fname(val))foo(max, [1, 2, 3])foo(min, [1, 2, 3])
Q15 | What is the output of the following?elements = [0, 1, 2]def incr(x):return x+1print(list(map(elements, incr)))
Q16 | What is the output of the following?elements = [0, 1, 2]def incr(x):return x+1print(list(map(incr, elements)))
Q17 | What is the output of the following?def to_upper(k):return k.upper()x = ['ab', 'cd']print(list(map(to_upper, x)))
Q18 | What is the output of the following?x = ['ab', 'cd']print(len(list(map(list, x))))
Q19 | Program code making use of a given module is called a ______ of the module.
Q20 | What is the output of the following piece of code?#mod1def change(a):b=[x*2 for x in a]print(b)#mod2def change(a):b=[x*x for x in a]print(b)from mod1 import changefrom mod2 import change#mains=[1,2,3]change(s)
Q21 | What is the output of the following program? tday=datetime.date.today()print(tday.month())
Q22 | Which of the following formatting options can be used in order to add „n? blank spacesafter a given string „S??
Q23 | What is the output of the following program?f = Nonefor i in range (5):with open("data.txt", "w") as f:if i > 2:breakprint(f.closed)
Q24 | To read the entire remaining contents of the file as a string from a file object infile, we use
Q25 | Suppose t = (1, 2, 4, 3), which of the following is incorrect?