Python MCQs with answers Page - 25

Here, you will find a collection of MCQ questions on Python. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 832.27K Points
Coach

Q. Is this code valid in Python?

Code:
>>> m=6,7,8,9
>>> m
  • (A) Yes, (6,7,8,9) will be printed
  • (B) No, many values will unpack
  • (C) Yes, 6 will be printed
  • (D) Yes, [6,7,8,9] will be printed

A

Admin • 832.27K Points
Coach

Q. Which function removes a set’s first and the last element from a list?

  • (A) pop
  • (B) dispose
  • (C) remove
  • (D) discard

A

Admin • 832.27K Points
Coach

Q. What will be the output of following python code?

Code:
values = [[3, 4, 5, 1], [33, 6, 1, 2]] 
v = values[0][0] 
for lst in values: 
for element in lst: 
if v > element: 
v = element print(v)
  • (A) 3
  • (B) 1
  • (C) 2
  • (D) 33

A

Admin • 832.27K Points
Coach

Q. Output of the following python program will be?

Code:
List = [True, 50, 10] 
List.insert(2, 5) 
print(List, "Sum is: ", sum(List))
  • (A) [True, 50, 10, 5] Sum is: 66
  • (B) [True, 50, 5, 10] Sum is: 65
  • (C) TypeError: unsupported operand type(s) for +: ‘int’ and ‘str’
  • (D) [True, 50, 5, 10] Sum is: 66

A

Admin • 832.27K Points
Coach

Q. Output of the following python program will be?

Code:
l = [1,2,6,5,7,8] 
l.insert(9)
  • (A) Error
  • (B) l=[9,1,2,6,5,7,8]
  • (C) l=[1,2,6,5,7,8,9]
  • (D) l=[1,2,6,5,9.7,8] (insert randomly at any position)

A

Admin • 832.27K Points
Coach

Q. What will be the output of following python code?

Code:
a=list((45,)*4) 
print((45)*4) 
print(a)
  • (A) (45,45,45,45).[45,45,45,45].
  • (B) 180[(45),(45),(45),(45)].
  • (C) 180[45,45,45,45].
  • (D) Syntax error

A

Admin • 832.27K Points
Coach

Q. Guess the output

Code:
a=[14,52,7]
b=a.copy()
b is a
  • (A) False
  • (B) True
  • (C) NA
  • (D) NA

A

Admin • 832.27K Points
Coach

Q. What will be the output of following python code?

Code:
a=[1,2,3,4]
b=[sum(a[0:x+1]) for x in range(0,len(a))]

print(b)
  • (A) 10
  • (B) [1,3,4]
  • (C) 4
  • (D) [1,3,6,10]

A

Admin • 832.27K Points
Coach

Q. Which of the following data type use Key:pair

  • (A) list
  • (B) tuple
  • (C) dictionary
  • (D) set

A

Admin • 832.27K Points
Coach

Q. Are nested if-else are allowed?

  • (A) No
  • (B) Yes
  • (C) NA
  • (D) NA

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ