70+ Python Objective Type Quiz & MCQs with Answers for Interview Preparation

Gyansetu Team Data Science

Whether you are preparing for a sequence certification exam or brushing for a job interview, these Python MCQs will test your knowledge on topics like data type, function, OOP, module, file handling, and more. If you are serious about mastering the python, see the python course in Gurgaon introduced by Gyansetu.

Q1. What is the correct file extension for python files?

 a) .PT

 b) .Pyth

 C) .py

 d) .Pyt

 Answer: c) .py

Q2. Which keywords are used to define a function in Python?

 A) Define

 B) Def

 C) ceremony

 d) Funk

 Answer: B) Def

Q3. What is the output of print (2 ** 3)?

 a) 6

 B) 8

 C) 9

 d) 23

 Answer: b) 8

Q4. Python is ___ typed language.

 A) strongly

 B) weakly

 C) dynamically

 D) statistically

 Answer: C) dynamically

Q5.  What will type([]) return?

 A) dict

 B) list

 C) set

 d) tuple

 Answer: B) List

📘 Section 2: Data Type and Operator

Q6. What is the result of bool(“False”) in Python?

a) False

b) True

c) 0

d) Error

 Answer: B) True

Q7. Which of the following is an immutable type?

a) list

b) dict

c) set

d) tuple

 Answer: d) tuple

Q8. Which operator is used for an exponentiation in the python?

 a) ^

 B) **

 C) ^^

 d) Exp

 Answer: B) **

Machine Learning with Python Course in Gurgaon

From Basics to Brilliance – Master Python with Us

Q9. What does len(“Python”) returns?

 a) 5

 B) 6

 C) 7

 D) error

 Answer: B) 6

Q10. What is the result of 5 // 2?

 a) 2.5

 B) 3

 C) 2

 d) 2.0

 Answer: C) 2

Q11. Which keywords are used for conditional branching?

 A) For

 B) if

 C) when

 d) Select

 Answer: B) if

Q12. What will range(0, 3) produce?

 a) [0, 1, 2]

 B) [0, 1, 2, 3]

 C) (0, 1, 2)

 d) {0, 1, 2}

 Answer: A) [0, 1, 2]

Q13. What is the output of while False:?

 a) Syntax error

 B) Anant loop

 C) nothing

 d) 0

 Answer: C) Nothing

Q14. Which keyword comes exits a loop ahead of time?

 A) return

 B) exit

 C) break

 d) stop

 Answer: C) break

Q15. What keywords continue for the next iteration?

 a) skip

 B) Continue

 C) Next

 d) pass

 Answer: B) Continue

Q16. What is the default return value of the function with a return statement?

 A) 0

 B) None

 C) Null

 D) error

 Answer: b) None

Q17. Which symbol is used to define *args?

 A) &

 B) *

 C) **

 D) @

 Answer: B) *

Q18. Which keywords are used to define an unnamed function?

 A) Def

 B) anon

 C) lambda

 d) Func

 Answer: C) lambda

Q19. What is a function inside another function called?

 A) inline

 B) nested

 C) local

 d) internal

 Answer: b) nested

Q20. Which keywords is used to reach a global variable inside a function?

 a public

 B) scope

 C) global

 d) Open

 Answer: C) global

Q21. How do you define a square in the python?

 A)object

 B) structure

 C) class

 d) Type

 Answer: C) class

Q22. What is the first argument of instance methods?

 A) this

 B) self

 C) class

 d) Obj

 Answer: B) self

Q23. What is the method overloading in Python?

 a) Multiple init

 B) not directly supported

 C) Part of heritage

 d) possible with decorators

 Answer: B) not directly supported

Q24. What is __init__ in Python?

 a) main function

 B) Constructor

 C) operator

 D) none

 Answer: b) Constructor

Q25. What is inheritance in Python?

 a) Copping code

 B) Code reuse

 C) Using the parent class

 D. All of the above

 Answer: d) All of the above

Machine Learning with Python Course in Gurgaon

Code Your Future: Start with Python Today

Q26. Which function is used to open a file in Python?

 a) open ()

 B) File ()

 C) Openfile ()

 d) Readfile ()

 Answer: A) open ()

Q27. What mode opens a file for writing in binary?

a) wb

b) wr

c) bw

d) rb

Answer: a) wb

Q28. Which keyword handles exceptions?

 A) catc

 B) throw

 C) except

 d) handle

 Answer: C) Except

Q29. What does finally block do?

 a) Executes only on error

 B) last executes

 C) Skip on return

 d) Optional  block

 Answer: B) last executes

Q30. Which exception is raised for divide-by-zero?

 a) ValueError

 B) ZerodivisionError

 C) ArithmeticError

 d) RuntimeErroe

 Answer: b) ZerodivisionError

Q31. What is the output of the set ([1,2,2,3])?

 a) [1,2,3]

 B) (1,2,3)

 C) {1,2,3}

 D) error

 Answer: c) {1,2,3}

Q32. Which method adds an item to a list?

 a) push ()

 B) Append ()

 C) add ()

 D) add ()

 Answer: B) Append()

Q33. What is the output of lane ({})?

 A) 0

 B) 1

 C) error

 D) none

 Answer: A) 0

Q34. Which data type is ordered and mutable?

 A) dict

 B) list

 C) set

 d) tuple

 Answer: B) List

Q35. Which method removes an item from a dictionary?

 a) delete ()

 B) pop ()

 C) remove ()

 d) discard ()

 Answer: B) pop ()

Q36. What is standard mathematics module in Python?

 a) py_math

 B) Mathematics

 C) math

 d) mathpy

 Answer: C) Mathematics

Q37. How do you import a module?

 a) Include modules

 B) Use module

 C) import module

 D) module

 Answer: C) Import module

Q38. Which library is used for data analysis?

 a) Panda

 B) Numpy

 C) matplotalib

 d) tinter

 Answer: A) Panda

Q39. NumPY is mainly used for this:

 a) Web scrapping

 B) GUI

 C) Numerical operation

 d) File I/O

 Answer: C) Numerical operation

Q40. Which function lists all the attributes of a module?

 a) module.info ()

 B) dir ()

 C) help ()

 d) show ()

 Answer: B) dir ()

Q41. What is the operator compared?

 A) Values

 B) ID

 C) Types

 d) Memory size

 Answer: B) IDs

Q42.What does id() function return?

 a) Address in memory

 B) data type

 C) Size of object

 d) Object reference

 Answer: A) Address in memory

Q43. Which keyword makes a generator?

 A) generate

 B) Def

 C) yield

 d) return

 Answer: C) yield

Q44. What is the output of the bool([])?

 A) True

 B) False

 C) []

 D) Error

 Answer: B) False

Q45. What does enumerate () return?

 a) keys

 B) Index-Price Couple

 C) only value

 d) only index

 Answer: B) Index-Value couple

Q46. What is [x for x in range(3)]?

 a dictionary

 B) list

 C) set

 d) tuple

 Answer: B) List

Q47. What is {x: x ** 2 for x in range (3)}?

  A)  list

 B) tuple

 C) Dictionary

 d) set

 Answer: C) Dictionary

Q48. Which understanding makes a set?

 A) [ ]

 B) {}

 C) ( )

 d) set ()

 Answer: b) {}

Q49. Can you use conditionals inside   comprehensions?

 A) No

 B) Yes

 C) only with lists

 d) only with dicts

 Answer: B) Yes

Q50.  What is the result of [i for i in range(5) if i % 2 == 0]?

 a) [1,3,5]

 B) [2,4]

 C) [0, 2, 4]

 D) Error

 Answer: c) [0, 2, 4]

.NET MVC course

From Beginner to Pro — Learn Python the Smart Way

Q51.What does “python”.upper() return?

a) PYTHON

b) python

c) Python

d) Error

Answer: a) PYTHON

Q52. What does ” hello “.strip() return?

a) “hello”

b) ” hello”

c) “hello “

d) ” hello “

Answer: a) “hello”

Q53. Which operator is used to concatenate strings?

 A) ,

 B) +

 C) &

 D) .

 Answer: B) +

Q54. What does “hello”[1] return?

a) h

b) e

c) l

d) o

Answer: b) e

Q55. What is the result of ‘A’ * 3?

 A) aaa

 B) A3

 C) error

 d) aaa3

 Answer: A) aaa

Q56. Which version introduced F-strings?

 a) 2.7

 B) 3.5

 C) 3.6

 d) 3.4

 Answer: C) 3.6

Q57. What does pass do?

 a) Break Loop

 B) skip Code

 C) placeholder

 d) Exit ceremony

 Answer: C) placeholder

Q58. What does None represent?

 A) wrong

 B) empty string

 C) no value

 d) 0

 Answer: C) no value

Q59. Which of these is a valid variable name?

 a) 1value

 b) _VALUE

 C) value@

 d) price location

 Answer: b) _value

Q60. What does a help(str) do?

 a) Shows the way of str

 B) deletes str

 C) Import Str

 D) None

 Answer: A) Shows methods of str

Q61. What does next () do?

 A) skips loop

 B) Calls Next function

 C) Returns the next item of Iterator

 d)  Repeats item 

 Answer: C) Returns the next item of Iterator

Q62. Which function creates a iterator?

 a) Iter ()

 B) Next ()

 C) Loop ()

 d) enum ()

 Answer: A) Iter ()

Q63. What is the output of the list (range (3))?

 a) [0,1,2]

 B) (0,1,2)

 C) Range (3)

 D) error

 Answer: A) [0,1,2]

Q64. Are generators iteratable?

 A) No

 B) only once

 C) Yes

 d) Sometimes

 Answer: C) Yes

Q65. What does the zip ([1,2], [3,4]) return?

 A) [(1,3), (2,4)]

 B) [1,3,2,4]

 C) (1,2,3,4)

 D) Error

 Answer: A) [(1,3), (2,4)]

📘 Section 14: Python IDES and Equipment

Q66. Which of these is not an IDE for Python?

a) PyCharm

b) VSCode

c) Eclipse

d) Sublime

Answer: c) Eclipse

Q67. What is used for PIP?

 a) debugging

 B) module installation

 C) test

 d) version control

 Answer: B) module installation

Q68. Which command installs a package in the python?

 A) Install the package

 B) PIP installed package

 C) Install Python

 d) Pkg gets

 Answer: b) PIP install package

Q69. Which file has dependence on python projects?

 a) dep.txt

 b) Install. txt

 C) requirements.txt

 d) Package.ini

 Answer: C) requirements.txt

Q70. Which extension is usually used for the Python Virtual Environment?

 a) .Pyenv

 b) Venv/

 c) .vpython

 d) .Venv

 Answer: b) venv/

Conclusion

Python is one of the most demanded programming languages ​​for development, automation and data science. These 70+ MCQ Python covers both original and advanced subjects to help you prepare for interviews and certificates. If you are looking at practically learning python with real -world projects, then join the python course in Gurgaon by Gyansetu and elevate your career in programming today!

Machine Learning with Python Course in Gurgaon

Learn. Code. Succeed. Enroll in a Python Course That Delivers Results

Gyansetu Team

Leave a Comment

Your email address will not be published. Required fields are marked *

Categories
Drop us a Query
+91-9999201478

Available 24x7 for your queries

Please enable JavaScript in your browser to complete this form.