Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python code please write a python code Write a class called linear to represents a linear equation (ax + b = 0). The class has

image text in transcribed

python code please write a python code

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? + b x + 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 = (-b = sqrt( b2 - 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

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions

Question

=+Show photos of consumers?

Answered: 1 week ago