Quiz Space

Programming in Python · End Term · 31 Aug 2025 · May 2025 term · Set QDF1

Question 3: Consider the following Python code:\ class Employee:\ def…

Question 3

+3 marksOne correct option

Consider the following Python code:
class Employee:
def __init__(self, name):
self.name = name
self.role = "Employee"
def show_details(self):
print(f"{self.name} works as {self.role}")
class Developer(Employee):
def __init__(self, name):
super().__init__(name)
self.role = "Developer"
def show_details(self):
print(f"{self.name} writes code as a {self.role}")
super().show_details()
class Manager(Employee):
def __init__(self, name):
super().__init__(name)
self.role = "Manager"
def show_details(self):
print(f"{self.name} manages tasks as a {self.role}")
super().show_details()
employees = [
Developer("Ananya"),
Manager("Rajeev"),
Developer("Kiran")
]
for emp in employees:
emp.show_details()
What will be the output of the code above?

  1. A

    Ananya writes code as a Developer
    Ananya works as Developer
    Rajeev manages tasks as a Manager
    Rajeev works as Manager
    Kiran writes code as a Developer
    Kiran works as Developer

  2. B

    Ananya writes code as a Developer
    Ananya works as Employee
    Rajeev manages tasks as a Manager
    Rajeev works as Employee
    Kiran writes code as a Developer
    Kiran works as Employee

  3. C

    Ananya works as Developer
    Rajeev works as Manager
    Kiran works as Developer

  4. D

    Developer
    Employee
    Manager
    Employee
    Developer
    Employee

Show answer

Correct answer

  • A

    Ananya writes code as a Developer
    Ananya works as Developer
    Rajeev manages tasks as a Manager
    Rajeev works as Manager
    Kiran writes code as a Developer
    Kiran works as Developer

Question 3 of 20 in the IIT Madras BS Programming in Python (Python) End Term paper sat on 31 Aug 2025, in the May 2025 term (IIT M FOUNDATION AN EXAM QDF3 31 Aug 2025). It carries 3 marks.

More questions from this paper

  1. Q1What will be the output of the following Python code?\ words = ["jacket", "cap", "scarf", "hat", "sock"]\ result = []\ …
  2. Q2Consider the following Python code:\ def evaluate_score(score):\ if score >= 90:\ if score == 100:\ print("Perfect Scor…
  3. Q4What will be the total number of lines printed when the following code is executed? scores = {\ "Aarav": [10, 20, 30],\…
  4. Q5What will be the output of the following code snippet?\ data = [(4, 7), (5, 8), (6, 6), (9, 3)]\ total = 0\ for a, b in…
  5. Q6What will be the output of the following code?\ items = ["apple", "banana", "cherry", "date", "fig", "grape", "kiwi"]\ …
  6. Q7Consider the use of the map() function in the following code snippets. Select all options that has the value [4, 9, 16,…
  7. Q8Which of the following statements about the exception handling behavior are TRUE? Select ALL that apply.\ def safe_divi…
  8. Q9Consider the following code snippet:\ def update_scores(scores, bonus):\ updated = []\ for score in scores:\ updated.ap…
  9. Q10Consider the following Python code:\ names = ["Aarav", "Bhuvan", "Charan", "Deepa"]\ marks = [88, 76, 92, 81]\ bonus = …
  10. Q11Consider the following Python code:\ with open("data.txt", "w") as f:\ for i in range(3):\ for j in range(i + 1):\ f.wr…
  11. Q12Consider the following Python code:\ a1 = (3, 6, 9, 12, 15, 18, 21, 24)\ a2 = a1[2:7]\ a3 = a2[::-1]\ a4 = tuple(x for …
  12. Q13Consider the following Python code:\ def transform(words):\ if not words:\ return []\ first = words[0][::-1]\ if first …
  13. Q14Consider the following Python code snippet:\ colors = ['red', 'blue', 'green', 'red', 'blue', 'red', 'yellow']\ freq = …
  14. Q15Consider the following Python code and answer the sub-questions:\ students = [\ {\ "name": "Arya",\ "subjects": {\ "Mat…
  15. Q16Consider the following Python code and answer the sub-questions:\ students = [\ {\ "name": "Arya",\ "subjects": {\ "Mat…
  16. Q17Consider the following Python code and answer the sub-questions:\ students = [\ {\ "name": "Arya",\ "subjects": {\ "Mat…
  17. Q18Consider the following Python code and answer the sub-questions:\ class Vehicle:\ total_vehicles = 0\ all_models = []\ …
  18. Q19Consider the following Python code and answer the sub-questions:\ class Vehicle:\ total_vehicles = 0\ all_models = []\ …
  19. Q20Consider the following Python code and answer the sub-questions:\ class Vehicle:\ total_vehicles = 0\ all_models = []\ …