ExamVeda
Login
Home
41
How can you create a private attribute in a Python class?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
42
What will be the output of the following Python code?
def add(c,k):
    c.test=c.test+1
    k=k+1
class A:
    def __init__(self):
        self.test = 0
def main():
    Count=A()
    k=0
 
    for i in range(0,25):
        add(Count,k)
    print("Count.test=", Count.test)
    print("k =", k)
main()
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
43
Which function overloads the // operator?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
44
What will be the output of the following Python code?
class test:
     def __init__(self,a):
         self.a=a
 
     def display(self):
         print(self.a)
obj=test()
obj.display()
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
45
What will be the output of the following Python code?
class Demo:
    def __init__(self):
        pass
 
    def test(self):
        print(__name__)
 
obj = Demo()
obj.test()
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
46
Special methods need to be explicitly called during object creation.
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
47
Which of the following is not a class method?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
48
What is the purpose of the super() function in Python classes?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
49
What will be the output of the following Python code?
class change:
    def __init__(self, x, y, z):
        self.a = x + y + z
 
x = change(1,2,3)
y = getattr(x, 'a')
setattr(x, 'a', y+1)
print(x.a)
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board
50
Which of the following Python code creates an empty class?
Discuss
Answer & Solution
Answer: Option B
No explanation is given for this question. Let's Discuss on Board