fork download
  1. class Mobile:
  2. def __init__(self, brand, price):
  3. print("Inside constructor")
  4. self.brand = brand
  5. self.price = price
  6. mob1=Mobile("Apple", 20000)
  7. print("Mobile 1 has brand", mob1.brand, "and price", mob1.price)
  8. mob2=Mobile("Samsung",3000)
  9. print("Mobile 2 has brand", mob2.brand, "and price", mob2.price)
Success #stdin #stdout 0.02s 9232KB
stdin
Standard input is empty
stdout
Inside constructor
Mobile 1 has brand Apple and price 20000
Inside constructor
Mobile 2 has brand Samsung and price 3000