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 the following Python code?

str1="learn python"
str2=""
str3=""
for x in str1:
if(x=="r" or x=="n" or x=="p"):
str2+=x
pass
if(x=="r" or x=="e" or x=="a"):
str3+=x
print(str2,end=" ")
print(str3)

rnpn ea
rnpn ear
rnp ea
rnp ear

2. Which of the following is False regarding loops in Python?

Loops are used to perform certain tasks repeatedly.
While loop is used when multiple statements are to executed repeatedly until the given condition becomes False
While loop is used when multiple statements are to executed repeatedly until the given condition becomes True.
for loop can be used to iterate through the elements of lists.

3. What will be the output of below Python code?

class Student:
def __init__(self,name,id):
self.name=name
self.id=id
print(self.id)
std=Student("Simon",1)
std.id=2
print(std.id)

1
    1
1
    2
2
    1
2
    2

4. You can delete properties on objects by using the ______ keyword.

delete
dedl
del
drop

5. What keyword would you use to add an alternative condition to an if statement?

else if
elseif
elif
None of the above

6. Which of the following is False?

String is immutable.
capitalize() function in string is used to return a string by converting the whole given string into uppercase.
lower() function in string is used to return a string by converting the whole given string into lowercase.
None of these.

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

str1="012"
num1=2
num2=0
for i in range(4):
num1+=2
for j in range(len(str1)):
num2=num2+num1
num3=num2%int(str1)
print(num3)

7
Infinite Loop
0
Error

8. Which of the following is incorrect regarding variables in Python?

Variable names in Python cannot start with number. However, it can contain number in any other position of variable name.
Variable names can start with an underscore.
Data type of variable names should not be declared
None of the above

9. What will be the output of below Python code?

tuple1=(2,4,3)
tuple3=tuple1*2
print(tuple3)

(4,8,6)
(2,4,3,2,4,3)
(2,2,4,4,3,3)
Error

10. Which one of the following is False regarding data types in Python?

In python, explicit data type conversion is possible
Mutable data types are those that can be changed.
Immutable data types are those that cannot be changed.
None of the above

Results