The code demonstrates Python's ability to dynamically add attributes to an instance of a class. 1. Instance Attributes: While name and age are initialized in the __init__ method, the salary attribute is added dynamically to the e1 instance after the object is created. Python allows this flexibility without any compile-time errors. 2. Output Explanation: When e1.display() is called, the display method prints name and age. Then, e1.salary is accessed and printed directly. 3. Execution Result: The code will output: Name: John, Age: 30 50000 This behavior demonstrates Python's dynamic nature and object-oriented principles. Why Other Options Are Incorrect: • A) It will print the name, age, and salary of the employee: The display method does not include salary, so salary is not printed there. • B) It will raise an AttributeError when accessing e1.salary: Python allows adding attributes dynamically; no error occurs. • D) It will execute but not print the salary attribute: e1.salary is explicitly printed in the last line. • E) It will fail to execute due to missing method to initialize salary: There is no requirement for salary to be initialized in the __init__ method.
(X + 140) liters of mixture A contains milk and water only such that quantity of water in it is (X – 100) liters less than quantity of milk in it. 75%...
A vessel holds (p + 200) liters of milk and p liters of honey. When 110 liters of honey and 50 liters of milk are added to the ve...
In a mixture of milk & water, 80 litres water is mixed due to which ratio changes from 3 : 4 to 1 : 3. Find initial quantity of mixture. (in litres)
From a container of Beer, a thief has stolen 25 litres of beer and replaced it with same quantity of water. He again repeated the same process. Thus in...
Two types of Pulses costs Rs. 240/kg and Rs. 340/kg. In what ratio should these be mixed so that obtained mixture sold at Rs. 324/kg to earn a profit of...
450 ml of a mixture contains milk and water in the ratio of 15 respectively. If 70 ml of water and 80 ml of milk are added into it, then the ratio of mi...
Quantity of water in a 250 litres mixture (alcohol + water) is 30 litres less than the quantity of alcohol in it. Find the quantity of water to be mixed...
140 litres of mixture X contains acetone and glycerine in the ratio 5:9, respectively. 70 litres of the mixture is withdrawn and labelled as mixture Y a...
Jar A contains ‘X’ ml mixture of milk and water in the ratio of 4 :3. Jar B contains ‘X’ ml mixture of milk and water in the rat...
A container can hold 1,000 liters of liquid. If it is filled with 30% water and 70% oil, how many liters of oil are in the container? If 50 liters of oi...