Python Basics MCQs
This section focuses on the "Basics" of the Python. These Multiple Choice Questions (mcq) should be practiced to improve the Python skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.
1. What will be the output of the following program on execution?
a=0
b=5
x=(a&b)|(a&a)|(a|b)
print("x")
View Answer
2. What will be the output of the following program on execution?
if False:
print ("inside if block")
elif True:
print ("inside elif block")
else:
print ("inside else block")
View Answer
3. Which of the following statements are correct?
(i) Python is a high level programming language.
(ii) Python is an interpreted language.
(iii) Python is a compiled language.
(iv) Python program is compiled before it is interpreted.
View Answer
4. Which of the following is incorrect variable name in Python?
View Answer
5. 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)
View Answer
6. What will be the result of following Python code snippet after execution?
str1=""
i=0
var2=1
while(i<3):
var1=1
if str1:
var2=var1*var2+5
else:
var2=var1*var2+1
i=i+1
print(var2)
View Answer
7. Which of the following is not a relational opeartor in Python?
View Answer
8. Suppose we have two sets A & B, then A < B is:
View Answer
9. Which of the following will result in error?
(i) list1[3]=list1[2]
(ii) list1[3]=list1[4]
(iii) list1.insert(1,78)
(iv) list1.pop(50)
If list1=[10,20,60,50]
View Answer
10. If str1="Programming Language"
What does str1.find("m") return?
View Answer
Also check :