Write the definition of a class WeatherForecast that provides the following behavior (methods):
No constructor need be defined. Be sure to define instance <span style="text-decoration-line: none;">variables</span> as needed by your "get"/"set" methods.
class WeatherForecast:
skies= ''
high = 0
low = 0
def set_skies(self, arg_str):
self.skies = arg_str
def get_skies(self):
return(self.skies)
def set_high(self, arg_int):
self.high = arg_int
def get_high(self):
return(self.high)
def set_low(self, arg_int):
self.low = arg_int
def get_low(self):
return(self.low)
# example test work
test = WeatherForecast()
test.set_skies('Mainly cloudy')
test.set_high(39)
test.set_low(-5)
print(test.get_skies(),test.get_low(),test.get_high())
Comments
Leave a comment