Python Basic MCQ

11. 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)

A. 6
B. True
C. 0
D. False

View Answer


12. 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

A. 12,648
B. 13,648
C. 13,660
D. 9,72

View Answer


13.  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

A. (var5/var4)>var3 and (var3*var2)>=(var1*var3)
B. (var5-var4)*var2
C. (var4/var2)>var1 and (var1*3)/var3
D. (var1/var3)>var4 or var5*2==var4

View Answer


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

for i in range(0 , -2 , -1):
print(i)

A. 0, -1
B. 0, -1, -1
C. -1, -2
D. Error

View Answer


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

A. hello world
B. hi
C. hi world
D. hello

View Answer


16. Which of the following are in correct order with respect to conditional statements in Python?
(i) if
(ii) else
(iii) elif .

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

View Answer


17. Which of the following two will give the same result?
(i) 42//2
(ii) 21%6
(iii) 12/4
(iv) 11*2.

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

View Answer


18. Which of the following is incorrect?.

A. List is a built-in data structure in Python
B. List can only have elements of same data type.
C. List is mutable.
D. Index of lists can be positive as well as negative.

View Answer


19. Which of the following operations cannot be done on string str1, where str1="LETSFINDCOURSE."?.

A. str1+="Learning made easy"
B. str1[1]="a"
C. print(str1[1])
D. str1[0:4]

View Answer


20. Which of the following would give "Harry" as output?
Given str1="Mary,Harry,John,Sam".

A. str1[4:9]
B. str1[5:10]
C. str1[4:10]
D. str1[5:9]

View Answer







Also check :


Discussion


* You must be logged in to add comment.