Python MCQ Quiz - Objective Question with Answer for Python - Download Free PDF

Last updated on Apr 22, 2024

Python, an open-source, high-level programming language known for its simplicity and versatility, has a wide range of applications, from web and game development to AI and data science. The Python MCQs given here are tailored to test and improve your understanding of the language's syntax, libraries, and frameworks. They cater to all levels, from beginners getting to grips with Python to intermediate coders wanting to reinforce their knowledge. Check how much you know about this computer programming language with Python MCQs given on this page.

Latest Python MCQ Objective Questions

Python Question 1:

Rajesh read the given csv file in a dataframe and he is not aware of how to skip the column heading while reading. Choose the correct argument required to solve this problem:















Hatch back






  1. sep
  2. end
  3. header
  4. head

Answer (Detailed Solution Below)

Option 3 : header

Python Question 1 Detailed Solution

The correct answer is header

Key Points

  • The read_csv function in Pandas (assuming you're using Pandas) takes several arguments to control how the CSV file is read.
  • The header argument specifically determines how the CSV file treats the first row.
  • By default, header=0 (or header='infer') assumes the first row contains column names.
  • To skip the column heading, set header=None. This tells read_csv to treat the first row as data and assign numerical indices (0, 1, 2, ...) as column names.

 Additional Information

  • If your CSV file has a different delimiter (e.g., semicolon instead of comma), you can use sep=';' to specify it.
  • Explore other read_csv arguments like dtype to define data types for columns or nrows to read a limited number of rows.

Python Question 2:

What are Python files containing Python definitions and statements called?

  1. Flowcharts
  2. Algorithms
  3. Modules
  4. Sequences

Answer (Detailed Solution Below)

Option 3 : Modules

Python Question 2 Detailed Solution

Python files containing Python definitions and statements are called modules. So the answer is (3).

Key Points

  •  A module is a file that contains Python code, such as functions, classes, and variables. Modules can be imported into other Python files, which allows you to reuse code and organize your code into smaller, more manageable files.
  • Modules are typically named with a .py extension. For example, a module named would contain Python code that can be imported into other Python files using the following statement:
    • import my_module
  • Once you have imported a module, you can access the code in that module using the module's name. For example, if you have a function called greet() in the module, you can call that function from another Python file using the following statement:
    • my_module.greet()
  • Modules are a powerful feature of Python that allow you to write more organized and reusable code.

Additional Information

  •  Flowcharts are visual representations of algorithms.
  • Algorithms are step-by-step instructions for solving a problem.
  • Sequences are ordered lists of elements.

Python Question 3:

find the output of the program

a = 1  

while True:  

    if a % 9 = = 0:  



    a += 1  

  1. 1 2 3 4 5 6 
  2. 1 2 3 4 5 6 7 8 
  3. 1 2 3 4 5 6 7 8 9
  4. none of these
  5. None of the above/More than one of the above

Answer (Detailed Solution Below)

Option 2 : 1 2 3 4 5 6 7 8 

Python Question 3 Detailed Solution

Correct answer is option BImportant Points

  • program start from 1
  • check condition  if a % 9 = = 0:  
  • then run and print all the value of a till a=8
  • when a=9 then condition is false 
  • then program Break 
  • So the answer is 1 2 3 4 5 6 7 8

Python Question 4:

What is the output of following code:

print (type(type(int)))

  1. type ‘int’
  2. error
  3. 0
  4. None of the above/More than one of the above

Answer (Detailed Solution Below)

Option 2 :

Python Question 4 Detailed Solution


Type function type() : It either returns the type of the object or returns a new type object based on the argument passed to it.


If we pass single object to type(), then it returns its type.

Here code is given as:

Print type(type(int))

It returns the class of the argument to which object belongs. So, it return type

Python Question 5:

What is output of the code in Python Language:

>>> str1 = ‘All the Best’

>>> str1[-3]

  1. "I"
  2. 'e'
  3. 'B'
  4. 'h'
  5. None of the above/More than one of the above

Answer (Detailed Solution Below)

Option 2 : 'e'

Python Question 5 Detailed Solution

Key Points

 str1 = ‘All the Best’ 

Here str1 is an array of continuous elements,




str1[3]=' '=str1[-9]




str1[7]=' '=str1[-5]





F1 Reena Shraddha 14.09.2021 D16

Hence the correct answer is 'e'.

Top Python MCQ Objective Questions

Python Question 6:

Which one is NOT a feature of Python language?

  1. Interpreted language
  2. Portable
  3. High level language
  4. Case Insensitive

Answer (Detailed Solution Below)

Option 4 : Case Insensitive

Python Question 6 Detailed Solution

Key Points

Python is a dynamic, high-level, free open source, and interpreted programming language. It supports object-oriented programming as well as procedural-oriented programming.

 Feature of Python language

  • Easy to code
  • Free and Open Source
  • Object-Oriented Language
  • GUI Programming Support
  • High-Level Language
  • Extensible feature
  • Python is a Portable language
  • Python is an Integrated language
  • Interpreted Language
  • Large Standard Library
  • Dynamically Typed Language
  • It case-sensitive programming language.

Hence the correct answer is Case insensitive.

Python Question 7:

What does this program print?

days = “Mon, Tue, Wed, Thu, Fri, Sat, Sun”


  1. Mon Tue Wed Thu Fri Sat Sun
  2. Fri
  4. T

Answer (Detailed Solution Below)

Option 3 : MTWTFSS

Python Question 7 Detailed Solution


Slicing: It is used to slice a particular sequence. We can specify where it starts and where it will end, how many characters can be skipped.


Here, given code is:

days = “Mon, Tue, Wed, Thu, Fri, Sat, Sun”


Output: In this, slice starts at the first character and includes every fifth character which is : MTWTFSS

It also count space as a character.

Important Point:

“Mon, Tue” in this 4th character is space

Python Question 8:

The command used to start Python from the command prompt is ________.

  1. execute python
  2. python
  3. py
  4. Both 2 and 3 are correct

Answer (Detailed Solution Below)

Option 4 : Both 2 and 3 are correct

Python Question 8 Detailed Solution

To execute python from the command prompt, 'python' and 'py' commands is entered.


The Correct Answer is Both py and python.

Python Question 9:

What is the output of the below program in python:

print(0.2 + 0.4 == 0.6)

  1. True
  2. False
  3. Error
  4. Depends on machine

Answer (Detailed Solution Below)

Option 2 : False

Python Question 9 Detailed Solution

0.2, 0.4 and 0.6 can not be represented accurately in binary.

The round off errors from 0.2 and 0.4 adds up

Hence there is a difference between (0.2 + 0.4) and 0.6.

This is because you can not compare floating point value, as it cannot be considered precise. 

Note:- If you run above program then we will get the output false.

Python Question 10:

What will be output of the following command in python?

print (r"\nhello")

  1. hello
  2. new line and hello
  3. \nhello
  4. Error

Answer (Detailed Solution Below)

Option 3 : \nhello

Python Question 10 Detailed Solution

In python language,

when 'r' or 'R' is used before the string, it converts the string into a raw string and the escape sequence like \n are not converted.

Hence the answer is \nhello.

Python Question 11:

What will be the result of the below command in python language:

round(0.4) - round(-0.5)

  1. 0
  2. 1
  3. 2
  4. -1

Answer (Detailed Solution Below)

Option 1 : 0

Python Question 11 Detailed Solution

In python language,

the system rounds off the number away from 0 when the number which has to be rounded off is halfway through.

This means,

round(0.4) = 0 and round(-0.5) = 0

This gives, 0-(-0) = 0

NOTE: It does not depend on the negative value.The round function is used to round the value.r

Eg: round(0 to 0.5) gives as 0.

round(-0.6 to -0.9) gives as -1.

Hence the answer is 0.

Python Question 12:

What is the output of the code in Python Language:

for num in range (3):
  if num > 0:
    print (num*100)

  1. 300, 300, 300
  2. 100, 100, 100
  3. 100, 200
  4. 300, 200 

Answer (Detailed Solution Below)

Option 3 : 100, 200

Python Question 12 Detailed Solution

Key PointsPython range() Basics: In simple terms, range() allows the user to generate a series of numbers within a given range. 

for num in range (3):

if num > 0:

print (num*100)

Here num has initially 0 and it prints num × 100 gives 0 as output and next iteration num is 1 and prints 100. After num has 2 and prints 200. And finally range become closes. 

Hence the correct answer is 100,200. 
Note:- for better understanding run the above program.

Python Question 13:

Which of following is keyword used in python?

  1. finally
  2. lambda
  3. for
  4. All of above

Answer (Detailed Solution Below)

Option 4 : All of above

Python Question 13 Detailed Solution

The correct answer is option 4.


In Python, reserved words are referred to as keywords. A keyword cannot be used as a variable name, function name, or other identifiers. 

Here's a list of all keywords in Python Programming:

False, await, else, import, pass, None, break, except, in, raise, True, class, finally, is, return, and, continue, for, lambda, try, as, def, from, nonlocal, while, assert, del, global, not, with, async, elif, if, or, yield.
The keywords listed above may change between Python versions. Some extras may be added, while others may be deleted. You may always retrieve a list of keywords in your current version by entering the following command at the prompt.
>>> import keyword
>>> print(keyword.kwlist)
Hence the correct answer is All of above.

Python Question 14:

What is the maximum length of a Python identifier?

  1. 33
  2. 28
  3. 14
  4. No fixed length specified

Answer (Detailed Solution Below)

Option 4 : No fixed length specified

Python Question 14 Detailed Solution

The correct answer is option 4.


Python Identifiers are names assigned to things such as classes, functions, variables, and so on. It helps in distinguishing one entity from another.

Rules for writing identifiers:

  • An identifier can be of any length.
  • Identifiers can be a mix of lowercase (a-z) or capital (A-Z) characters, numerals (0-9), or underscore(_). Names like myClass, var_1 and print_this_to_screen, all are valid example.
  • A digit cannot be the first character of an identifier. Variable1 is an acceptable name, but 1variable is not.
  • Keywords cannot be used as identifiers.
  • In our identifier, we cannot use special characters such as !, @, #, $, percent, and so on.


​In python an Identifier there is no fixed length so the identifier can be of any length.

Hence the correct answer is No fixed length specified.

Python Question 15:

Python is a/an _____ 

  1. Programming language
  2. Web browser
  3. Malware
  4. Operating system

Answer (Detailed Solution Below)

Option 1 : Programming language

Python Question 15 Detailed Solution

The correct answer is Programming language.

Key Points

  • Python
    • It is one of the most popular programming languages in the world.
    • It is commonly used for developing websites and software, task automation, data analysis, and data visualization..
    • It has become a 'go-to' in data science, allowing data analysts and other professionals to use the language to conduct complex statistical calculations, create data visualizations, build machine learning algorithms, etc.
    • It can build a wide range of different data visualizations, like line and bar graphs, pie charts, histograms, and 3D plots.
  • It was created by Guido van Rossum, and first released on February 20, 1991