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__
Question
Solution 1
The private data fields in the given Python class are __a
and self.__b
.
In Python, private variables begin with double underscores __
. However, if they also end with double underscores, they are special variables rather than private variables. Python uses these special variables for specific
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
Similar Questions
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__
Which of these is a private data field?def Demo:def __init__(self): __a = 1 self.__b = 1 self.__c__ = 1 __d__= 1
class Demo: def __init__(self): self.a = 1 self.__b = 1 def get(self): return self.__bobj = Demo()obj.a=45print(obj.a)
Which of the following is correct?class A: def __init__(self): self.count=5 self.count=count+1a=A()print(a.count)560Error
class fruits: def __init__(self): self.price = 100 self.__bags = 5 def display(self): print(self.__bags)obj=fruits()obj.display()