Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Solve py python language Write a class called linear to represents a linear equation (ax +b = 0). The class has the following methods: A

image text in transcribed

Solve py python language

Write a class called linear to represents a linear equation (ax +b = 0). The class has the following methods: A constructor with one tuple argument called coefficients to define and initialize two instant variables, a and b, with default values of 0. getCoff method that returns a tuple of coefficients a and b. getRoot method that returns the root of equation (root=-a/b). isRoot method with one real number argument that checks if a given number is the equation's root or not. Use getRoot to get the root. An overloading method for the str() operator that returns the equation string represented as ax+b=0 An overloading method for the == operator that returns True only if coefficients, a and b, are the same for both linear objects. Write a class called quadratic that is derived from linear class to represents a quadratic equation (cx+bx+ a = 0). The class has the following methods: A constructor with one tuple argument called coefficients assigned to a hidden (private) instant variable, c, and the two linear object attributes, a and b, with default values of 0. Call the super class constructor for a and b variables. An overriding method for getCoff method that returns a tuple of coefficients cb, and a respectively An overriding method for getRoot that returns a tuple of roots for the quadratic equation (roots = (-b sqrt(b? - 4ac) }/2c). Use math library. An overriding method for isRoot method with one real number argument that checks if a given number is one of the equation's root or not. Use getRoot to get the roots. An overloading method for the str() operator that returns the equation string represented as CX^2+bx+a=0. Write a code to create objects/instances of the above mentioned classes and test your code

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

Step: 3

blur-text-image

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

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

=+differences in home- and host-country costs of living?

Answered: 1 week ago

Question

=+derived from the assignment will balance the costs?

Answered: 1 week ago