Start learning 50% faster. Sign in now
Get Started with ixamBee
Start learning 50% faster. Sign in nowThe 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.
Which of the following Insurance initiatives to be launched in 2024 is women-centric distribution channel at the Gram Sabha level?
Which of the following Articles is related with Fundamental Duties?
What is the full form of VIPER, NASA's lunar rover set to explore the Moon's South Pole in late 2024 on a 100-day mission?
The Vijayanagar kingdom was established by ________ in 1336.
Who is the author of the book ‘The Soul of a Butterfly: Reflections on Life’s Journey’?
In September 2020, which of the three bills was passed by the parliament aimed at transforming agriculture in the country and raising farmer’s income?...
The United Nations Sustainable Development Goal 6 strives to ______.
Which of the following sentence is/are correct about crop rotation?
1. Crop rotation helps return nutrients to the soil without synthetic inpu...
What is the name of the multiple rocket launcher (MBRL) developed by the Defence Research and Development Organisation (DRDO) for the Indian Army?
Which river forms the largest delta in the world?