Python MCQs with answers Page - 154

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 is the output of the following code?

Code:
x = [10, 20, 30]
print(x[1:])
  • (A) [20, 30]
  • (B) [10, 20]
  • (C) 20
  • (D) Error

A

Admin • 831.35K Points
Coach

Q. Which of these creates an empty set?

  • (A) {}
  • (B) set()
  • (C) []
  • (D) ()

A

Admin • 831.35K Points
Coach

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

Code:
x = [1,2,3]
y = x
x.append(4)
print(y)
  • (A) [1,2,3]
  • (B) [1,2,3,4]
  • (C) Error
  • (D) None

A

Admin • 831.35K Points
Coach

Q. Which statement is used to exit a loop in Python?

  • (A) exit
  • (B) stop
  • (C) break
  • (D) quit

A

Admin • 831.35K Points
Coach

Q. What is the output of the following code?

Code:
print('a' * 3)
  • (A) aaa
  • (B) a3
  • (C) Error
  • (D) ['a','a','a']

A

Admin • 831.35K Points
Coach

Q. Which of the following functions converts a number to a string?

  • (A) str()
  • (B) string()
  • (C) toString()
  • (D) convert()

A

Admin • 831.35K Points
Coach

Q. Which symbol is used for string formatting in Python's old style?

  • (A) #
  • (B) $
  • (C) %
  • (D) &

A

Admin • 831.35K Points
Coach

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

Code:
x = None
print(type(x))
  • (A) <class 'NoneType'>
  • (B) <class 'str'>
  • (C) <class 'bool'>
  • (D) Error

A

Admin • 831.35K Points
Coach

Q. What is the output of the following code?

Code:
print(chr(65))
  • (A) 65
  • (B) A
  • (C) Error
  • (D) a

A

Admin • 831.35K Points
Coach

Q. Which method is used to split a string into a list?

  • (A) split()
  • (B) divide()
  • (C) partition()
  • (D) separate()

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