Skip to content

Instantly share code, notes, and snippets.

@Kimjunkuk
Created January 3, 2022 02:20
Show Gist options
  • Select an option

  • Save Kimjunkuk/052dae95050d212c7d4c0cabd412414f to your computer and use it in GitHub Desktop.

Select an option

Save Kimjunkuk/052dae95050d212c7d4c0cabd412414f to your computer and use it in GitHub Desktop.
5. Question 5 We have two pieces of furniture: a brown wood table and a red leather couch. Fill in the blanks following the creation of each Furniture class instance, so that the describe_furniture function can format a sentence that describes these pieces as follows: "This piece of furniture is made of {color} {material}"
class Furniture:
color = ""
material = ""
table = Furniture()
table.color="brown"
table.material="wood"
couch = Furniture()
couch.color="red"
couch.material="leather"
def describe_furniture(piece):
return ("This piece of furniture is made of {} {}".format(piece.color, piece.material))
print(describe_furniture(table))
# Should be "This piece of furniture is made of brown wood"
print(describe_furniture(couch))
# Should be "This piece of furniture is made of red leather"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment