Created
January 3, 2022 02:20
-
-
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}"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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