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

using python
using python Write a class called linear to represents a linear equation

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 c, b, and a , respectively An overriding method for getRoot that returns a tuple of roots for the quadratic equation (roots = (-6 t 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

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!