class Demo: def __init__(self): self.a = 1 self.__b = 1 def get(self): return self.__bobj = Demo()obj.a=45print(obj.a)

Question

class Demo: def __init__(self): self.a = 1 self.__b = 1 def get(self): return self.__bobj = Demo()obj.a=45print(obj.a)
🧐 Not the exact question you are looking for?Go ask a question

Solution 1

The code you've provided is written in Python. It defines a class Demo with an initializer method, a private attribute __b, a public attribute a, and a method get to return the value of the private attribute.

Here's a step-by-step explanation:

  1. class Demo: This line is defining a new c Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study prob
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solv

This problem has been solved

Similar Questions

class Demo: def __init__(self): self.a = 1 self.__b = 1 def get(self): return self.__bobj = Demo()obj.a=45print(obj.a)

what is the output of following python code? class myclass:    def __init__(self,a):        self.a = a        print(self.a)o=myclass()

what is the output of following python code? class myclass:    def __init__(self,a):        self.a = a        print(self.a)o=myclass("Welcome")

Which of these is a private data field?def Demo:def __init__(self): __a = 1 self.__b = 1 self.__c__ = 1 __d__= 1

Which of these is a private data field?def Demo:def __init__(self): __a = 1 self.__b = 1 self.__c__ = 1 __d__= 1 __a __b__c____d__

1/3