Computer scienceProgramming languagesPythonObject-oriented programmingMethods

Methods and attributes

Paint

Report a typo

Below is the class House. Create a method called paint that takes a color as an argument and paints the house that color (i.e. modifies the attribute color with the value of the method argument).

The method doesn't need to return any values or print any messages. You also do NOT need to take any input!

It's better to add self.color = None to __init__ and update the value in the paint method.
Write a program in Python 3
class House:
def __init__(self, floors):
self.floors = floors

# create the method here
___

Create a free account to access the full topic