Python 3 Suppose there is a class AirConditioner . The class supports the follow
ID: 653966 • Letter: P
Question
Python 3
Suppose there is a class AirConditioner . The class supports the following behaviors: turning the air conditioner on, off, and setting the desired temperature. The following methods are provided for these behaviors: turn_on and turn_off , which accept no arguments and return no value, andset_temp , which accepts an int argument and returns no value.
There is a reference variable my_ac to an object of this class, which has already been created. Invoke a method telling the object to set the air conditioner to 72 degrees.
Explanation / Answer
class AirConditioner:
def turn_on:
if self.temp>self.maxtemp:
print "turn on ac":
else:
print "no need of ac":
def turn_off:
if self.temp< self.mintemp:
print "turn off ac"
else: printf "run the ac":
def set_temp(self,temp):
self.temp=temp;
Ac=AirConditioner(72,30,20)
print(Ac.set_temp())
These are the overview of code which sets the temperature of ac to 72.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.