Python MCQ Questions Set-2

Python MCQ Questions:-

Q1. What is the output of the following code?

print(type(type()))
a)Error
b)Null
c)None
d)None of the above

Answer a

Q2.What is the output of following code?

print(type(type))
a) <class ‘type’>
b)Error
c) <class ‘none’>
d)None of the above

Answer a

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

Answer b

Q4. What is the output of following code?


list1=[None]*3
print(list1)
a) [None, None, None]
b)[ ]
c)[ ‘ ‘,’ ‘,’ ‘]
d)None of the above

Answer a

Q5. What is the output of 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

Answer b

Q6. What is the output of the 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

Answer a

Q7.What is the output of following code?

print([] or {})
a) {}
b)[]
c)True
d)False

Answer a

Q8. What is the output of following code?

class Truth:
pass
x=Truth()
print(bool(x))
a)None
b)Error
c) True
d)None of the above

Ans c

Q9. print(“-%5d0”,989)

a) -%5d0 989
b)Error
c)-09890
d)98900

Ans a

Q10. What is the type of each element in sys.argv?

a) set
b) list
c) tuple
d) string

Answer: d

Q11. What is called when a function is defined inside a class?

(A) Module
(B) Class
(C) Another Function
(D) Method

Answer: (D)

Q12 What is the output of following code?

print(~~5)
a)5
b)-6
c)101
d)None of the above

Answer a

Q13.
list1=[]
list1[0]=100
print(list1)

a)100
b)[100]
c)Error
d)None of the above

Answer c

Q14. What is the output of 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

Answer a

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

Answer a

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

Answer a

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

Answer b

18.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
Answer a

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

Answer a

19.What is the output of following code?

x=2
y=x<<2
y=~y+1
print(y)
a)4
b)-4
c)-8
d)None of the above

Answer c

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

Ans a

Q22. Python language was developed by_____.

a)Monty Python
b)Rossum
c)James
d)None of the above

Ans b

Q23. In the following code, X is __.

X=(123)
a)integer
b)tuple
c)set
d)None of the above

Ans a

Q24. Python is____________.

a) low-level language
b)object-oriented language
c)scripting language
d)both b and c

Ans d

Q25. Python language is platform dependent.

a)True
b)False

Ans b

More Articles:-

Python MCQ Questions Set-1

Python Program to Check Whether a Number is Prime or Not

Top 5 programming languages

Leave a Reply

Your email address will not be published. Required fields are marked *