75 Python Object Oriented Programming Exercises Volume 1 by Learning Edcorner

75 Python Object Oriented Programming Exercises Volume 1 by Learning Edcorner

Author:Learning, Edcorner [Learning, Edcorner]
Language: eng
Format: epub
Published: 2021-08-31T16:00:00+00:00


46. Implement a class called Bucket that takes any number of named arguments (keyword arguments - use **kwargs ) when creating an instance. The name of the argument is the name of the instance attribute, and the value for the argument is the value for the instance attribute.

Example:

[IN]: bucket = Bucket(apple=3.5)

[IN]: print(bucket. _dict_)

[OUT]: {'apple': 3.5}

Then create instance named bucket by adding the following attributes with their values:

• apple = 3.5

• milk = 2.5

• juice = 4.9

• water = 2.5

In response, print the value of _dict_ attribute for the bucket instance.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.