Python Programming Quiz


Play this Python quiz that will help you to excel in C++ certification exams, placements etc. This Python programming quiz consist of 10 questions that you need to solve in 10 minutes. We’ve specially designed this quiz so that you can quickly acquaint to the pattern of questions you can be asked in placement drives, certification exams etc. This Python programming test enables you to assess your knowledge of Python programming.

Take the Free Practice Test



Python MCQs

Practice Python MCQ Questions, which will help you to understand Python programming related concepts and also helps you to prepare for placements, technical rounds, interviews, competitive exams etc.

Python Quiz

Try Free Python Quiz, to start a quiz you need to login first, after login you will get start quiz button and then by clicking on that you can start quiz. You will get 10 Minutes to answer all questions.

Python Quiz

1. What will be the output of following Python code?

set1={2,5,3}
set2={3,1}
set3={}
set3=set1&set2
print(set3)

{3}
{}
{2,5,3,1}
{2,5,1}

2. How is a function declared in Python?

def function function_name():
declare function function_name():
def function_name():
declare function_name():

3. Suppose B is a subclass of A, to invoke the __init__ method in A from B, what is the line of code you should write?

A.__init__(self)
B.__init__(self)
A.__init__(B)
B.__init__(A)

4. Where is function defined?

Module
class
Another Function
All of the above

5. Which of the following would give an error?

list1=[]
list1=[]*3
list1=[2,8,7]
None of the above

6. What will the below Python code will return?

list1=[0,2,5,1]
str1="7"
for i in list1:
str1=str1+i
print(str1)

70251
7
15
Error

7. What will be the output of the following Python code?

for i in range(0,2,-1):
print("Hello")

Hello
Hello Hello
No Output
Error

8. In a Python program, a control structure:

Defines program-specific data structures
Directs the order of execution of the statements in the program
Dictates what happens before the program starts and after it terminates
None of the above

9. What is a python file with .py extension called?

package
module
directory
None of the above

10. Choose the correct option.

In Python, a tuple can contain only integers as its elements.
In Python, a tuple can contain only strings as its elements.
In Python, a tuple can contain both integers and strings as its elements.
In Python, a tuple can contain either string or integer but not both at a time.

Results