Python MCQs with answers Page - 6

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. Which of the following is the truncation division operator in Python?

  • (A) |
  • (B) //
  • (C) /
  • (D) %

A

Admin • 831.35K Points
Coach

Q. Which of the following functions is a built-in function in python?

  • (A) factorial()
  • (B) print()
  • (C) seed()
  • (D) sqrt()

A

Admin • 831.35K Points
Coach

Q. Which of the following is the use of id() function in python?

  • (A) Every object doesn’t have a unique id
  • (B) Id returns the identity of the object
  • (C) All of the mentioned
  • (D) None

A

Admin • 831.35K Points
Coach

Q. The following python program can work with ____ parameters.

Code:
def f(x):
    def f1(*args, **kwargs):
           print("Sanfoundry")
           return x(*args, **kwargs)
    return f1
  • (A) any number of
  • (B) 0
  • (C) 1
  • (D) 2

A

Admin • 831.35K Points
Coach

Q. What will be the output of the following Python function?

Code:
min(max(False,-3,-4), 2,7)
  • (A) -4
  • (B) -3
  • (C) 2
  • (D) False

A

Admin • 831.35K Points
Coach

Q. Which of the following is not a core data type in Python programming?

  • (A) Tuples
  • (B) Lists
  • (C) Class
  • (D) Dictionary

A

Admin • 831.35K Points
Coach

Q. What will be the output of the following Python expression if x=56.236?

Code:
print("%.2f"%x)
  • (A) 56.236
  • (B) 56.23
  • (C) 56.0000
  • (D) 56.24

A

Admin • 831.35K Points
Coach

Q. Which of these is the definition for packages in Python?

  • (A) A set of main modules
  • (B) A folder of python modules
  • (C) A number of files containing Python definitions and statements
  • (D) A set of programs making use of Python modules

A

Admin • 831.35K Points
Coach

Q. What will be the output of the following Python function?

Code:
len(["hello",2, 4, 6])
  • (A) Error
  • (B) 6
  • (C) 4
  • (D) 3

A

Admin • 831.35K Points
Coach

Q. What is the order of namespaces in which Python looks for an identifier?

  • (A) Python first searches the built-in namespace, then the global namespace and finally the local namespace
  • (B) Python first searches the built-in namespace, then the local namespace and finally the global namespace
  • (C) Python first searches the local namespace, then the global namespace and finally the built-in namespace
  • (D) Python first searches the global namespace, then the local namespace and finally the built-in namespace

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