This article contains Python MCQ Quiz. Attempting this MCQ will help you to evaluate your knowledge and skills.
Q1. What is the output of the following code?
print(type(type()))
a)Error
b)Null
c)None
d)None of the above
Q2.What is the output of the following code?
print(type(type))
a)
b)Error
c)
d)None of the above
Q3 What is the output of following code?
class cc:
def f1(self,a,b):
self.a=a
self.b=b
return self.a+self.b
o=new cc()
print(o.f1(4,4))
a)8
b)Error
c)4
d)None of the above
Q4. What is the output of following code?
list1=[None]*3
print(list1)
a) [None, None, None]
b)[ ]
c)[ ‘ ‘,’ ‘,’ ‘]
d)None of the above
Q5 What is the output of the following code?
string = “my name is x”
for i in string:
print (i, end=”, “)
a)my name is x
b) m, y, , n, a, m, e, , i, s, , x,
c) “my name is x”
d) None of the above
Q6 . What is the output of following code?
l=[1,’0′, 2, 0, ‘hello’, ”, []]
print(list(filter(bool, l)))
a) [1, ‘0’, 2, ‘hello’]
b)Error
c)[ ]
d)None of the above
Q7.What is the output of following code?
print([] or {})
a) {}
b)[]
c)True
d)False
Q8. What is the output of the following code?
class Truth:
pass
x=Truth()
print(bool(x))
a)None
b)Error
c) True
d)None of the above
Q9.
print(“-%5d0”,989)
a) -%5d0 989
b)Error
c)-09890
d)98900
Q10. What is the type of each element in sys.argv?
a) set
b) list
c) tuple
d) string
Q11. What is called when a function is defined inside a class?
(A) Module
(B) Class
(C) Another Function
(D) Method
Q12 What is the output of the following code?
print(~~5)
a)5
b)-6
c)101
d)None of the above
Q13.
list1=[]
list1[0]=100
print(list1)
a)100
b)[100]
c)Error
d)None of the above
Q14. What is the output of the following code?
class c1:
@classmethod
def m1(cls):
print(“hello”)
ob=c1()
ob.m1()
a)hello
b)Address of object ob
c)Error
d)None of the above
Q15. What is the output of following code?
class myclass:
@staticmethod
def m1():
print(“hello”)
ob=myclass()
ob.m1()
a)hello
b)error
c)Address of ob object
d)None of the above
Q16. What is the output of following code?
class class1:
def init(self,a,b,c):
self.a=a
self._b=b
self.__c=c
class class2:
pass
o=class1(1,2,3)
print(self.a)
a)Error
b)1
c)2
d)None of the above
- What is the output of following code?
class class1:
def init():
print(“class1’s init“)
class class2(class1):
def init():
print(“class2’s init“)
ob=class2()
a) class1’s init
b)Error
c) class2’s init
d)None of the above - What is the output of following code?
class class1:
def init(me,a):
me.a=a
print(a)
ob=class1(10)
a)10
b)Error - What is the output of following code?
a=1,2,3,4
print(a)
a) (1, 2, 3, 4)
b)1
c)4
d)Error
- What is the output of the following code?
x=2
y=x<<2
y=~y+1
print(y)
a)4
b)-4
c)-8
d)None of the above
Q21. What is the output of following code?
class c1:
c=0
def init(self):
c=c+1
print(c)
o=c1()
print(o.c)
a)Error
b)0
c)1
d)None of the above
Q22. Python language was developed by_____.
a)Monty Python
b)Rossum
c)James
d)None of the above
Q23. In the following code, X is __.
X=(123)
a)integer
b)tuple
c)set
d)None of the above
Q24. Python is____________.
a) low-level language
b)object-oriented language
c)scripting language
d)both b and c
Q25. Python language is platform-dependent.
a)True
b)False