Python MCQ Questions and Answers PDF [395 MCQs]

Python MCQ Questions and Answers PDF. Helpful for TCS, O Level and all other computer competitive exams where is Python programming language related Questions asks.

Python MCQ Questions and Answers

1. Which type of programming does Python support?

a) Object-oriented programming      

b) structure programming

c) functional programming               

d) All of these

Ans. d

2. Is Python case sensitive when dealing with identifiers?

a) no   

b) yes  

c) Machine dependent           

d) None of these

Ans. b

3. All keywords in Python are in ________

a) Capitalized             

b) lower case

c) UPPER CASE                       

d) None of these

Ans. d

4. Which of the following is used to define a block of code in Python language?

a) Indentation

b) Key

c) Brackets

d) All of these

Ans. a

5. Python supports the creation of anonymous functions at runtime, using a construct called ____

a) pi

b) anonymous

c) lambda

d) none of these

Ans. c

6. Which one of the following has the same precedence level?

a) Addition and Subtraction

b) Multiplication, Division and Addition

c) Multiplication, Division, Addition and Subtraction

d) Addition and Multiplication

Ans. a

7. Which one of the following has the highest precedence in the expression?

a) Exponential

b) Addition

c) Multiplication

d) Parentheses

Ans. d

8. Which of these in not a core data type?

a) Lists

b) Dictionary

c) Tuples

d) Class

Ans. d

9. What is the order of precedence in python?

a) Exponential, Parentheses, Multiplication, Division, Addition, Subtraction

b) Exponential, Parentheses, Division, Multiplication, Addition, Subtraction

c) Parentheses, Exponential, Multiplication, Division, Subtraction, Addition

d) Parentheses, Exponential, Multiplication, Division, Addition, Subtraction

Ans. d

10. Which of the following is true for variable names in Python?

a) underscore and ampersand are the only two special characters allowed

b) unlimited length

c) all private members must have leading and trailing underscores

d) none of the mentioned

Ans. b

11. Operators with the same precedence are evaluated in which manner?

a) Left to Right

b) Right to Left

c) Can’t say

d) None of the mentioned

Ans. a

12. Which of the following is the truncation division operator in Python?
a) |     

b) //    

c) /      

d) %

Ans. b

13. 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 of the mentioned

Ans. b

14. 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

Ans. b

15. 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

Ans. c

16. Which one of the following is not a keyword in Python language?

a) pass

b) eval

c) assert

d) nonlocal

Ans. b

17. Which module in the python standard library parses options received from the command line?

a) getarg        

b) getopt        

c) main                       

d) os

Ans. b

18. What arithmetic operators cannot be used with strings in Python?

a) *     

b) –

c) +     

d) All of the mentioned

Ans. b

19. Which of the following statements is used to create an empty set in Python?

a) ( )

b) [ ]

c) { }

d) set()

Ans. d

20. To add a new element to a list we use which Python command?
a) list1.addEnd(5)
b) list1.addLast(5)
c) list1.append(5)
d) list1.add(5)

Ans. c

21. Which one of the following is the use of function in python?
a) Functions don’t provide better modularity for your application
b) you can’t also create your own functions
c) Functions are reusable pieces of programs
d) All of the mentioned

Ans. c

22. What is the maximum possible length of an identifier in Python?

a) 79 characters

b) 31 characters

c) 63 characters

d) none of the mentioned

Ans. d (Identifiers can be of any length)

23. Which of the following is a Python tuple?

a) {1, 2, 3}

b) {}

c) [1, 2, 3]

d) (1, 2, 3)

And. D

24. Which of the following is a feature of Python DocString?

a) In Python all functions should have a docstring

b) Docstrings can be accessed by the __doc__ attribute on objects

c) It provides a convenient way of associating documentation with Python modules, functions, classes, and methods

d) All of the mentioned

Ans. d

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

a) Every object in Python doesn’t have a unique id

b) In Python Id function returns the identity of the object

c) None of the mentioned

d) All of the mentioned

Ans. b

26. The process of pickling in Python includes ____________

a) conversion of a Python object hierarchy into byte stream

b) conversion of a datatable into a list

c) conversion of a byte stream into Python object hierarchy

d) conversion of a list into a datatable

Ans. a

27. Why are local variable names beginning with an underscore discouraged?

a) they are used to indicate a private variables of a class

b) they confuse the interpreter

c) they are used to indicate global variables

d) they slow down execution

Ans. a

28. Which of the following is true for variable names in Python?

a) unlimited length

b) all private members must have leading and trailing underscores

c) underscore and ampersand are the only two special characters allowed

d) none of the mentioned

Ans. a

29. Which is the correct operator for power(xy)?

a) X^y             

b) X**y

c) X^^y                       

d) None of the mentioned

Ans. b

30. Which one of these is floor division?

a) /

b) //

c) %

d) None of the mentioned

Ans. b

Python MCQ Questions and Answers PDF Download here [395 MCQs]
Best Computer MCQ Book for Competitive Exams [7000 MCQs]
WordPress MCQ Questions and Answers PDF [Top 100 MCQs]