Question: class PlanType: . def-init--(self, basic-rate, default-mins, rate-permin, has-rollover-True): create/initialize instance variables for all four non-self parameters. You can assume all arguments are valid and there

 class PlanType: . def-init--(self, basic-rate, default-mins, rate-permin, has-rollover-True): create/initialize instance variablesfor all four non-self parameters. You can assume all arguments are valid

class PlanType: . def-init--(self, basic-rate, default-mins, rate-permin, has-rollover-True): create/initialize instance variables for all four non-self parameters. You can assume all arguments are valid and there is no need to perform any checking. . def _str_(self): create/return a string as in this example: "PlanType (25.50,_200,Le.50,True)" . def _repr__(self): create/return a string identical to the__str__output. * Don't import anything, and you can use all built-ins/methods that are otherwise available. * adding definitions: You may add additional methods and functions in support of your solution. * displaying things: _str__and_ _repr_are used by many other places in Python to get a string representation of the object. Specifically, str() calls__str_, and repr() calls_repr__, on any objects they receive as arguments. _str__often generates a human-centric representation, appropriate for a human reading what is present.__repr_often generates a Python-centric representation. The goal of_repr__is actually to have a string that could be evaluated to re-generate an identical object. In general, we would quite prefer it to look like a valid constructor call, if possible. Ultimately, we can have the same representation in str _ and repr_ if we'd like; in fact, when we didn't explicitly describe two different string representations for_str__and__repr_ to return, we can define one in terms of the other, like this def _repr_(self): return str(self) Just remember the original intent of-st-vs-rep-. It's good practice to define-init- and_repr_immediately before writing any extra methods in a Python class at a minimum, and perhaps also eq_as well. str

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!