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")

A. 1
B. 5
C. 0
D. None of the above

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")

A. inside if block
B. inside elif block
C. inside else block
D. Error

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.

A. i, ii
B. i, iv
C. ii, iii
D. ii, iv

View Answer


4. Which of the following is incorrect variable name in Python?

A. variable_1
B. variable1
C. 1variable
D. _variable

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)

A. 7
B. Infinite Loop
C. 0
D. Error

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)

A. 16
B. 12
C. 11
D. 4

View Answer


7. Which of the following is not a relational opeartor in Python?

A. >=
B. <=
C. =
D. !=

View Answer


8. Suppose we have two sets A & B, then A < B is:

A. True if len(A) is less than len(B).
B. True if A is a proper subset of B.
C. True if the elements in A when compared are less than the elements in B.
D. True if A is a proper superset of B.

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]

A. i, iii
B. i, iv
C. ii, iv
D. ii, iii

View Answer


10. If str1="Programming Language"
What does str1.find("m") return?

A. Number of occurances of "m" in string str1.
B. Index positions of "m" in the string str1.
C. It returns the whole string str1 if it contains "m".
D. It returns the index position of first occurance of "m" in the string str1.

View Answer






Also check :


Discussion


* You must be logged in to add comment.