Question: Write a bhaskara function that receives the values of a, b, and c and returns x1 and x2. To return multiple values from a

Write a bhaskara function that receives the values of a, b, and

 

Write a bhaskara function that receives the values of a, b, and c and returns x1 and x2. To return multiple values from a function, you can use a data structure like a list as follows return [x1, x2]. Use the following results to validate the correctness of your function: 1) a = 3, b = -2, c = -1 => x1 = 1 2) a = 2, b = 12, c = -4 => x1 = 1 In [1]: # Write the function code here def bhaskara(a, b, c): delta b**2 - 4*a*c x1 = (-b + delta**0.5) / (2*a) x2 = (-b-delta **0.5)/(2*a) return [x1, x2] [(2, -2, -1), (2, 12, -4)] inputs = for a, b, c in inputs: and x2 = -1/3 and x2 = -7 x1, x2 = bhaskara(a, b, c) print (f"a {a}, b = {b}, c = {c} => X1 = (x1) and X2 = {X2}") In [2]: # Write a program that calls the function and display the returned results.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

It appears there are some syntax errors and issues in your provided ... View full answer

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 Programming Questions!