Python MCQs with answers Page - 8

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:
print(type(5 / 2))
print(type(5 // 2))
  • (A) float and int
  • (B) int and float
  • (C) float and float
  • (D) int and int

A

Admin • 831.35K Points
Coach

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

Code:
a = [1, 2, 3, 4, 5]
sum = 0
for ele in a:
   sum += ele 
print(sum)
  • (A) 15
  • (B) 0
  • (C) 20
  • (D) None of these

A

Admin • 831.35K Points
Coach

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

Code:
count = 0
while(True):
   if count % 3 == 0:
       print(count, end = " ")
   if(count > 15):
       break;
   count += 1
  • (A) 0 1 2 ….. 15
  • (B) Infinite Loop
  • (C) 0 3 6 9 12 15
  • (D) 0 3 6 9 12

A

Admin • 831.35K Points
Coach

Q. Which of the following concepts is not a part of Python?

  • (A) Pointers.
  • (B) Loops.
  • (C) Dynamic Typing.
  • (D) All of the above.

A

Admin • 831.35K Points
Coach

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

Code:
def solve(a, b):
   return b if a == 0 else solve(b % a, a)
print(solve(20, 50))
  • (A) 10
  • (B) 20
  • (C) 50
  • (D) 1

A

Admin • 831.35K Points
Coach

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

Code:
def solve(a):
   a = [1, 3, 5]
a = [2, 4, 6]
print(a)
solve(a)
print(a)
  • (A) [2, 4, 6]. [2, 4, 6]
  • (B) [2, 4, 6], [1, 3, 5]
  • (C) [1. 3. 5], [1, 3, 5]
  • (D) None of these

A

Admin • 831.35K Points
Coach

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

Code:
def func():
   global value
   value = "Local"
   
value = "Global"
func()
print(value)
  • (A) Local
  • (B) Global
  • (C) None
  • (D) Cannot be predicted

A

Admin • 831.35K Points
Coach

Q. Which of the following statements are used in Exception Handling in Python?

  • (A) try
  • (B) except
  • (C) finally
  • (D) All of the above

A

Admin • 831.35K Points
Coach

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

Code:
a = 3
b = 1 
print(a, b)
a, b = b, a 
print(a, b)
  • (A) 3 1 1 3
  • (B) 3 1 3 1
  • (C) 1 3 1 3
  • (D) 1 3 3 1

A

Admin • 831.35K Points
Coach

Q. Which of the following types of loops are not supported in Python?

  • (A) for
  • (B) while
  • (C) do-while
  • (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