Question & Answer: The following python code has a missing attribute. If we run this code as it is now, we will get an error…..

The following python code has a missing attribute. If we run this code as it is now, we will get an error message. Debug the code by adding the missing attribute and run the program and get the output.

#Encapsulaiton

class Employee:

def __init__(self):

self.__ssn = ‘307 878 876’

def pirntInfo(self):

print(self.__ssn)

employee1 = Employee()

Expert Answer

class Employee:
def __init__(self):
self.__ssn = ‘307 878 876’
def pirntInfo(self):
print(self.__ssn)

“This would create first object of Employee class”
employee1 = Employee()
employee1 .pirntInfo()

Still stressed from student homework?
Get quality assistance from academic writers!