ExamVeda
Login
Home
51
What will be the output of the following Python code?
class test:
    def __init__(self):
        self.variable = 'Old'
        self.Change(self.variable)
    def Change(self, var):
        var = 'New'
obj=test()
print(obj.variable)
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
52
Is the following Python code correct?
>>> class A:
	def __init__(self,b):
		self.b=b
	def display(self):
		print(self.b)
>>> obj=A("Hello")
>>> del obj
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
53
Let A and B be objects of class Foo. Which functions are called when print(A + B) is executed?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
54
What will be the output of the following Python code?
class fruits:
    def __init__(self, price):
        self.price = price
obj=fruits(50)
 
obj.quantity=10
obj.bags=2
 
print(obj.quantity+len(obj.__dict__))
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
55
What is hasattr(obj,name) used for?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
56
What will be the output of the following Python code?
class stud:
   ‘Base class for all students’
   def __init__(self, roll_no, grade):
      self.roll_no = roll_no
      self.grade = grade
   def display (self):
      print("Roll no : ", self.roll_no,  ", Grade: ", self.grade)
print(student.__doc__)
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
57
What is the output of the following code:
class Parent:
x = 10
class Child(Parent):
pass
obj = Child()
print(obj.x)
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
58
How can you check if an object belongs to a specific class in Python?
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
59
__del__ method is used to destroy instances of a class.
Discuss
Answer & Solution
Answer: Option A
No explanation is given for this question. Let's Discuss on Board
60
Which function overloads the >> operator?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board