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?
a=0
b=6
x=(a&b)|(a&a | a&b)
y=not(x)
print(y)
View Answer
3. 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
4. What will be the values of var1 and var2 after the execution of program?
var=3
var1=0
var2=var1+1
while(var<7):
var2=var2+var1
if(var1%2==0):
var=var+1
var1=var1+1
else:
var2=var2*var1
var1=var1+3
View Answer
5. 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
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
View Answer
7. Which of the following is incorrect variable name in Python?
View Answer
8. What will be the output of following Python code snippet?
for i in range(0 , -2 , -1):
print(i)
View Answer
9. 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
10. What will be the result of following Python code snippet after execution?
a=0
b=1
if (a and b):
print("hi")
elif(not(a)):
print("hello")
elif(b):
print("hi world")
else:
print("hello world")
View Answer
11. 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
12. Which of the following are in correct order with respect to conditional statements in Python?
(i) if
(ii) else
(iii) elif
View Answer
13. Which of the following is not a relational opeartor in Python?
View Answer
14. Which of the following two will give the same result?
(i) 42//2
(ii) 21%6
(iii) 12/4
(iv) 11*2
View Answer
15. Suppose we have two sets A & B, then A < B is:
View Answer
16. Which of the following is incorrect?
View Answer
17. 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
18. Which of the following operations cannot be done on string str1, where str1="LETSFINDCOURSE."?
View Answer
19. If str1="Programming Language"
What does str1.find("m") return?
View Answer
20. Which of the following would give "Harry" as output?
Given str1="Mary,Harry,John,Sam"
View Answer
Also check :
Discussion