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. Arrange this in order of Precedence.
1. Exponentiation
2. Parentheses
3. Multiplication and Division
4. Addition and Subtraction

1,2,3,4
2,1,3,4
1,2,4,3
2,3,1,4

2. Which one of the following is correct way of declaring and initialising a variable, x with value 5?

int x
     x=5
int x=5
x=5
declare x=5

3. Which of the following functions clears the regular expression cache?

re.sub()
re.pos()
re.purge()
re.subn()

4. Which of the following is correct?

class Book:
	def __init__(self,author):
		self.author=author
book1=Book("V.M.Shah")
book2=book1

Both book1 and book2 will have reference to two different objects of class Book.
id(book1) and id(book2) will have same value.
It will throw error as multiple references to same object is not possible.
None of the above

5. When does the else statement written after loop executes?

When break statement is executed in the loop
When loop condition becomes false
Else statement is always executed
None of the above

6. Which of the given options has same output as given statement?

If var1=7
var2=5
var3=1
var4=10
var5=20
(var1*var2)>(var5+var4*var3) and ((var5+var3)/var1)>=(var2-2)/var3

(var5/var4)>var3 and (var3*var2)>=(var1*var3)
(var5-var4)*var2
(var4/var2)>var1 and (var1*3)/var3
(var1/var3)>var4 or var5*2==var4

7. The continue statement can be used in?

while loop
for loop
do-while
Both A and B

8. How many local and global variables are there in the following Python code?

var1=5
def fn():
var1=2
var2=var1+5
var1=10
fn()

1 local, 1 global variables
1 local, 2 global variables
2 local, 1 global variables
2 local, 2 global variables

9. Operators with the same precedence are evaluated from?

Left to Right
Right to Left
Depends on Compiler
None of the above

10. What will be the output of the following code

 a = 1
b = ++a
print(b is a)

True
False
Error
None of the above

Results