Question: using python Write a function that returns the two roots of a quadratic equation as a tuple of complex values. Structure the program as follows

using python

Write a function that returns the two roots of a quadratic equation

using python Write a function that returns the two roots of a

as a tuple of complex values.

Structure the program as follows so that the program when run, prints the roots for the following three cases:

quadratic equation as a tuple of complex values. Structure the program as follows so that the program when run, prints the roots for the following three cases: Program structure import math class complex: re = 0

Program structure

import math

class complex: re = 0 im = 0 def __init__(self,r,i): self.re = r self.im = i def format(self): return "{}{:+f}i".format(self.re,self.im)

def solvequadratic(a,b,c):

.im = 0 def __init__(self,r,i): self.re = r self.im = i def

.

return (complex( , ),complex( , ))

#____main____

a= solvequadratic(5,1,2)

print ("5x^2 + x + 2 = 0 -> x= ", a[0], " or ", a[1])

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!