Question

Consider the following Python code snippet: class Employee:     def __init__(self, name, age):         self.name = name         self.age = age     def display(self):         print(f"Name: {self.name}, Age: {self.age}") e1 = Employee("John", 30) e1.salary = 50000 e1.display() print(e1.salary) What will happen when the above code is executed?

A It will print the name, age, and salary of the employee.
B It will raise an AttributeError when accessing e1.salary.
C It will print Name: John, Age: 30 and 50000 on separate lines.
D It will execute but not print the salary attribute.
E It will fail to execute due to missing method to initialize salary.
Practice Next

Hey! Ask a query