Python Create Class Airconditioner Class Supports Following Behaviors Turning Air Conditio Q37045155

In Python, create the class AirConditioner. The class supportsthe following behaviors: turning the air conditioner on and off.The following methods are provided for these behaviors: turn_on andturn_off. Both the turn_on method and the turn_off method accept noarguments and return no value. The object name is my_ac, which hasalready been created. Invoke the turn_on method to turn the airconditioner on.

I’ve used if/then statements, which MPL has rejected. My answeris:

class AirConditioner:

def turn_on(self):

self.is_on=True

self.my_ac=”on”

def turn_on(self):

self.is_on=False

self.my_ac=”off”

which I know is wrong, but it’s hard to figure out what MPL(python code checked on a Linux machine) wants.


Solution


color{blue}Answer:

my_ac.turn_on()

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.