Top 50+ Solved Python Programming MCQ Questions Answer

From 16 to 30 of 39

Q. What is the output of the following program?data = [2, 3, 9]temp = [[x for x in[data]] for x in range(3)]print (temp)

a. [[[2, 3, 9]], [[2, 3, 9]], [[2, 3, 9]]]

b. [[2, 3, 9], [2, 3, 9], [2, 3, 9]]

c. [[[2, 3, 9]], [[2, 3, 9]]]

d. None of these

  • a. [[[2, 3, 9]], [[2, 3, 9]], [[2, 3, 9]]]

Q. What is the output of the following program?L1 = [1, 2, 3, 4]L2 = L1L3 = L1.copy()L4 = list(L1)L1[0] = [5]print(L1, L2, L3, L4)

a. [5, 2, 3, 4] [5, 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 4]

b. [[5], 2, 3, 4] [[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4]

c. [5, 2, 3, 4] [5, 2, 3, 4] [5, 2, 3, 4] [1, 2, 3, 4]

d. [[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 4]

  • d. [[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 4]

Q. 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)

a. 5 None [3, 7, 9]

b. 5 1 [3, 7, 9]

c. 5 1 [3, 7, 9]

d. 5 None [1, 3, 7, 9]

  • a. 5 None [3, 7, 9]

Q. 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)

a. KeyError

b. {0: 1, 7: 0, 1: 1, 8: 0}

c. {0: 0, 7: 0, 1: 1, 8: 1}

d. {1: 1, 7: 2, 0: 1, 8: 1}

  • c. {0: 0, 7: 0, 1: 1, 8: 1}

Q. What is the output of the following program?D = dict()for i in range (3): for j in range(2): D[i] = jprint(D)

a. {0: 0, 1: 0, 2: 0}

b. {0: 1, 1: 1, 2: 1}

c. {0: 0, 1: 0, 2: 0, 0: 1, 1: 1, 2: 1}

d. TypeError: Immutable object

  • b. {0: 1, 1: 1, 2: 1}

Q. What is the type of each element in sys.argv?

a. set

b. list

c. tuple

d. string

  • d. string

Q. What is the length of sys.argv?

a. number of arguments

b. number of arguments + 1

c. number of arguments – 1

d. none of the mentioned

  • b. number of arguments + 1
Subscribe Now

Get All Updates & News