Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

More Books

Students also viewed these Databases questions

Question

Complexity of linear search is O ( n ) . Your answer: True False

Answered: 1 week ago

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago