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?Solution
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.
The US government should establish a new expert regulatory body to ______ the huge and growing threat posed by disinformation on digital platforms.
...If you …… enrol, then the details of the authorised signatory will not be added to the Network, which means those companies will not be,……….....
Directions: Below given sentences contain two blanks. Fill in the blanks with appropriate words.Â
The musician's mesmerizing performance _____...
In the question given below, two sentences are given with one blank each. From the given options, choose the word that correctly fits both sentences.
In the question below, a sentence is given with two words missing. You are given five options containing a pair of words that can fill the blanks makin...
Fill in the blanks with appropriate forms of modals from the alternatives given below each sentence.
 _____ you rather have tea or coffee?
Fill in the blank with the most appropriate phrase.
He needed to __________ his plan and everything would be fine.
The booking was made and the taxi was _______ a few minutes.
1) built
2) said
3) issued
4) made
5) nurtured
Fill in the blank/s with suitable Word/s:
We need to _________ the report carefully and _________ any errors.