CSE MCQs :: Python MCQs
- What is setattr() used for?
- What are the methods which begin and end with two underscore characters called?
-
Which of these is a private data field?def Demo:def __init__(self):__a = 1self.__b = 1self.__c__ = 1__d__= 1
- When will the else part of try-except-else be executed?
-
What is the output of the code shown below?def f(x):yield x+1print("test")yield x+2g=f(9)
-
The output of the code shown below is:int('65.43')
-
What is the output of the following piece of code?class A():def disp(self):print("A disp()")class B(A):passobj = B()obj.disp()
- Which of the following statements is true?
- Which function overloads the == operator?
-
What is the output of the following piece of code?class Demo:def __init__(self):self.x = 1def change(self):self.x = 10class Demo_derived(Demo):def change(self):self.x=self.x+1return self.xdef main():obj = Demo_derived()print(obj.change())main()