doubt clearing Of surprise Test

  • doubt clearing Of surprise Test

    Posted by Debjit Kundu on March 8, 2024 at 5:44 pm

    class Aircraft:

    def __init__(self, speed, altitude):

    self.speed = speed

    self.altitude = altitude

    def move(self):

    print(f”Aircraft is moving at {self.speed} mph and altitude {self.altitude} feet.”)

    class Vehicle:

    def __init__(self, fuel_level, dangerous_cargo):

    self.fuel_level = fuel_level

    self.dangerous_cargo = dangerous_cargo

    def check_fuel_level(self):

    if self.fuel_level < 2:

    print(“Fuel level is low!”)

    else:

    print(“Fuel level is sufficient.”)

    def check_dangerous_cargo(self):

    if self.dangerous_cargo:

    print(“Aircraft is carrying a dangerous cargo.”)

    else:

    print(“no danger.”)

    class PassengerPlane(Aircraft, Vehicle):

    def __init__(self, speed, altitude, fuel_level, dangerous_cargo, passenger_capacity):

    super().__init__(speed, altitude)

    super().__init__(fuel_level, dangerous_cargo)

    self.passenger_capacity = passenger_capacity

    def move(self):

    super().move()

    print(f”Passenger plane with {self.passenger_capacity} passengers on board.”)

    def main():

    speed = 500 # mph

    altitude = 30000 # feet

    fuel_level = 3.0 # tons (sufficient fuel)

    dangerous_cargo = True # Yes, the aircraft is carrying dangerous cargo

    passenger_capacity = 150

    plane = PassengerPlane(speed, altitude, fuel_level, dangerous_cargo, passenger_capacity)

    plane.move()

    plane.check_fuel_level()

    plane.check_dangerous_cargo()

    if __name__ == “__main__”:

    main()

    AttributeError: 'PassengerPlane' object has no attribute 'fuel_level

    (i can see passengerplane has ‘fuel_level’ attribute)

    Debjit Kundu replied 9 months, 3 weeks ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

Log in to reply.

Get In Touch