Every function which is built-in function which start with 'is' like isdigit(),issue() are only for asking is value 'True' or 'False'.
As goes for isinstance() function. It state that ask instance or we can say object that it belong to certain class like ask Tata that it belong to car class or ask Tesla that it belong to electric car class or not.
class Car: total_car=0 def __init__(self,brand,model): self.brand=brand self.model=model Car.total_car+=1 def full_function(self): return f"{self.brand} {self.model}" def fuel_type(self): return "Petrol or Desiel" @staticmethod def general_description(): return "Cars mean of transportation" class ElectricCar(Car): def __init__(self,brand,model,battery_size): super().__init__(brand,model) self.battery_size=battery_size def fuel_type(self): return "Electric Charge" Tata=Car("TATA","Sedan") My_Tesla=ElectricCar("Tesla","ModelX",'85KWH') print(isinstance(Tata,Car)) print(isinstance(My_Tesla,ElectricCar))
Output: True True
Top comments (0)