Following quiz provides Multiple Choice Questions (MCQs) related to Python. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.
Q 1 - What is output for −
a = ['he', 'she', 'we']
The method join() takes list of string as input and returns string as output. It removes ', ' and add the given string with join to the list.
Q 2 - What is output for −
b = [11,13,15,17,19,21]
b[::2] :- it iterates over the list with ‘2’ increments
Q 3 - What is output of following code −
Since there are no separators in the given string so the output is the same string.
Q 4 - What is output of following code −
def func(x, ans): if(x==0): return 0 else: return func(x-1, x+ans) print(func(2,0))
Q 5 - What is the output of the following code?
import math def main(): math.cos(math.pi) main() print(main())
None is printed because function does not return the value.
Q 6 - Which among them is used to create an object?
constructor is used to create an object of class.
Q 7 - Analyze the code −
print(''Recursive Function'') def factorial(n): return(n*factorial(n-1)) factorial(4)
there is no condition in the code to stop the function.
Q 8 - How to create a frame in Python?
Frame() method is used to make a frame in python.
Q 9 - Select the valid code to bind a canvas with a key event p −
Q 10 - Which module is used in python to create Graphics?