Python MCQs with answers Page - 10

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 • 831.35K Points
Coach

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

Code:
word = "Python Programming"
n = len(word)
word1 = word.upper()
word2 = word.lower()
converted_word = ""
for i in range(n):
 if i % 2 == 0:
   converted_word += word2[i]
 else:
   converted_word += word1[i]
print(converted_word)
  • (A) pYtHoN PrOgRaMmInG
  • (B) Python Programming
  • (C) python programming
  • (D) PYTHON PROGRAMMING

A

Admin • 831.35K Points
Coach

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

Code:
square = lambda x: x ** 2
a = []
for i in range(5):
   a.append(square(i))
   
print(a)
  • (A) [0, 1, 4, 9, 16]
  • (B) [1, 4, 9, 16, 25]
  • (C) [0, 1, 2, 3, 4]
  • (D) [1, 2, 3, 4, 5]

A

Admin • 831.35K Points
Coach

Q. As what datatype are the *args stored, when passed into a function?

  • (A) List.
  • (B) Tuple.
  • (C) Dictionary.
  • (D) None of the above.

A

Admin • 831.35K Points
Coach

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

Code:
def tester(**kwargs):
   for key, value in kwargs.items():
       print(key, value, end = " ")
tester(Sunday = 1, Monday = 2, Tuesday = 3, Wednesday = 4)
  • (A) Sunday 1 Monday 2 Tuesday 3 Wednesday 4
  • (B) Sunday 1
  • (C) Wednesday 4
  • (D) None of the above

A

Admin • 831.35K Points
Coach

Q. As what datatype are the *kwargs stored, when passed into a function?

  • (A) Lists.
  • (B) Tuples.
  • (C) Dictionary.
  • (D) None of the above.

A

Admin • 831.35K Points
Coach

Q. Which of the following blocks will always be executed whether an exception is encountered or not in a program?

  • (A) try
  • (B) except
  • (C) finally
  • (D) None of These

A

Admin • 831.35K Points
Coach

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

Code:
from math import *
a = 2.19
b = 3.999999
c = -3.30
print(int(a), floor(b), ceil(c), fabs(c))
  • (A) 2 3 -3 3.3
  • (B) 3 4 -3 3
  • (C) 2 3 -3 3
  • (D) 2 3 -3 -3.3

A

Admin • 831.35K Points
Coach

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

Code:
set1 = {1, 3, 5}
set2 = {2, 4, 6}
print(len(set1 + set2))
  • (A) 3
  • (B) 6
  • (C) 0
  • (D) Error

A

Admin • 831.35K Points
Coach

Q. What keyword is used in Python to raise exceptions?

  • (A) raise
  • (B) try
  • (C) goto
  • (D) except

A

Admin • 831.35K Points
Coach

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

Code:
s1 = {1, 2, 3, 4, 5}
s2 = {2, 4, 6}
print(s1 ^ s2)
  • (A) {1, 2, 3, 4, 5}
  • (B) {1, 3, 5, 6}
  • (C) {2, 4}
  • (D) None of the above

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