English

Find the error in the following program to get the given output? class Fruits: def __init__(self, f1, f2): self.f1=f1 self.f2=f2 def display(self): print("Fruit 1 = %s, Fruit 2 = %s

Advertisements

Question

Find the error in the following program to get the given output?

class Fruits:
 def __init__(self, f1, f2):
 self.f1=f1
 self.f2=f2
 def display(self):
 print("Fruit 1 = %s, Fruit 2 = %s" %(self.f1, self.f2))
 F = Fruits ('Apple', 'Mango')
 del F.display
 F.display()

Output
 Fruit 1 = Apple, Fruit 2 = Mango
One Line Answer
Advertisements

Solution

In line No. 8, del F.display will not come.

shaalaa.com
Sample Programs to Illustrate Classes and Objects
  Is there an error in this question or solution?
Chapter 10: Python Classes and objects - Evaluation [Page 188]
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×