Python MCQ and Answers – Part 2
This collection of Python Multiple Choice Questions and Answers (MCQs): Quizzes & Practice Tests with Answer.
1. Which function inserts an object at a given index into a list?
A list.index(obj)
B list.insert(index, obj)
C list.pop(obj=list[-1])
D list.remove(obj)
2. In python, what is the correct method to load a module?
A include math
B import math
C #include math.h
D using math
3. What is the output for 'python' [-3]
?
A ‘h’
B ‘t’
C ‘o’
D Error: negative index.
4. What is the output of the following code: print type(type(int))
?
A type ‘int’
B type ‘type’
C Error
D 0
5. What is the output of the following code?
[ (a,b) for a in range(3) for b in range(a) ]
A [(1,0),(2,0),(2,1)]
B [(1,0),(2,1),(2,1)]
C [(0,0),(1,1),(2,2)]
D [(1,0),(2,1),(3,2)]
6. What is the output of the following code?
myList = ['a','b','c','d'] print "".join(myList)
A [‘a’,’b’,’c’,’d’]
B abcd
C Null
D Error
7. What is the output of the following code?
print(max('welcom to stackhowto.com'))
A x
B w
C y
D .
8. What is the output of the following code?
chr(ord('A'))
A 65
B A
C a
D Erreur
9. What is the output of the following code?
x = lambda a : a + 10 print(x(5))
A 10
B 5
C 15
D Error
10. When a function is defined in a class, it is called ______?
A Module
B Class
C Method
D None of the above