Which of these is a private data field?def Demo:def __init__(self): __a = 1 self.__b = 1 self.__c__ = 1 __d__= 1
Question
Solution 1
In Python, a private data field is denoted by double underscores before the variable name. So, in the given code, self.__b
is a private data field.
The variable __a
is a local variable, not a data field. The variables self.__c__
and __d__
are not considered private fields because they have
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
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__
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()