Knowee
Questions
Features
Study Tools

Ques 9 / 10:ReportMarks: +1-0What will be the output of below Python code?class A():    def __init__(self,count=100):        self.count=countobj1=A()obj2=A(102)print(obj1.count)print(obj2.count)

Question

Ques 9 / 10:ReportMarks: +1-0What will be the output of below Python code?class A():    def init(self,count=100):        self.count=countobj1=A()obj2=A(102)print(obj1.count)print(obj2.count)

🧐 Not the exact question you are looking for?Go ask a question

Solution

The output of the Python code will be:

100 102

Explanation:

The class A is defined with an initializer method (init) that takes one argument 'count' with a default value of 100.

When obj1 is created without any argument, the default value of count (100) is used.

When obj2 is created with an argument (102), this value overrides the default value.

So, when we print obj1.count, it outputs 100 and when we print obj2.count, it outputs 102.

This problem has been solved

Similar Questions

What will be the output of below Python code?class A():    def __init__(self,count=100):        self.count=countobj1=A()obj2=A(102)print(obj1.count)print(obj2.count)

What will be the output of below Python code?class A():    def __init__(self,count=100):        self.count=countobj1=A()obj2=A(102)print(obj1.count)print(obj2.count)100100100102102102ErrorClear ResponseSave & Next

What will be the output of the following Python code? class student: def __init__(self): self.marks = 97 self.__cgpa = 8.7 def display(self): print(self.marks)obj=student()print(obj._student__cgpa)

What will be the output of the following Python code?(i) class A: (2)def __init__(self,x):self.x = xdef count(self,x):self.x = self.x+1class B(A):def __init__(self, y=0):A.__init__(self, 3)self.y = ydef count(self):self.y += 1def main():obj = B()obj.count(

What will be the output of the following Python code?class A: def __init__(self): self.__i = 1 self.j = 5  def display(self): print(self.__i, self.j)class B(A): def __init__(self): super().__init__() self.__i = 2 self.j = 7 c = B()c.display()2 71 51 72 5

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.