1.
- A person can work. A person can work. An employee works. A person eats food.
- Try again!
- A person can work. An employee works. A person eats food.
- Try again!
- The code won't compile.
- Try again!
- A person can work. An employee works. A person eats food. A person eats food.
- Correct! Since Employee inherited from Person, the food method works for the Employee class as well.
- A person can work. A person can work. An employee works. A person eats food. A person eats food.
- Try again!
Q-1: Given the below code, what would be printed (ignore newlines and spacing between sentences)?
class Person:
def work(self):
print("A person can work.")
def food(self):
print("A person eats food.")
class Employee(Person):
def work(self):
print("An employee works.")
p1 = Person()
p2 = Employee()
p1.work()
p2.work()
p1.food()
p2.food()