Write a bhaskara function that receives the values of a, b, and c and returns x1...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Answer rating: 100% (QA)
It appears there are some syntax errors and issues in your provided ... View the full answer
Related Book For
Financial Accounting and Reporting a Global Perspective
ISBN: 978-1408076866
4th edition
Authors: Michel Lebas, Herve Stolowy, Yuan Ding
Posted Date:
Students also viewed these programming questions
-
Calculate the price of a new system if Probability of System Crash = 20% Cost of System Crash = 100,000 Hours of Operation = 2,500 Operational Cost per Hour = 10
-
Telstar uses job order costing. The T-accounts below summarize its production activity for the year. Raw Materials Inventory Debit Credit 45,500 24,750 8,500 Factory Wages Payable Debit 126,500...
-
In 2004 the Khumalos sold their farm to Peter and Jenny, a couple who are married in community of property. There are two homesteads on the farm. A right of habitatio was reserved over the smaller...
-
How are financial statements adjusted for exchange rates?
-
Using Mohrs circle, determine for the quarter ellipse of Problem 9.67 the moments of inertia and the product of inertia with respect to new axes obtained by rotating the x and y axes about O (a)...
-
If the 2-kg block passes over the top B of the circular portion of the path with a speed of 3.5 m/s, calculate the magnitude NB of the normal force exerted by the path on the block. Determine the...
-
Consider the simple linear regression model fit to the tank pressure and volume data in Problem 2.16. Problem 2.16 Carroll and Spiegelman ("The Effects of Ignoring Small Measurement Errors in...
-
Tim Howard has been offered the opportunity of investing $36,125 now. The investment will earn 11% per year and at the end of that time will return Tim $75,000. How many years must Tim wait to...
-
3. On the General server, use vi/vim to create a file called circle.c and enter the following C code: #include int main() { } float radius, area; printf("Enter the radius: "); scanf("%f", &radius);...
-
Assistant police chief Todd Beck wants to analyze the citys historic crime data in order to better allocate police resources in the future. He collects data over the past two years. Each record in...
-
Calculate the retained earnings balance at the end of the period. Preference shares have been treated as debt in the financials. Net income 100,550.0 Retained earnings, end of prior year 397,150.0...
-
Sheffield Company had net credit sales during the year of $1450000 and cost of goods sold of $820000. The balance in accounts receivable at the beginning of the year was $160000, and the end of the...
-
On January 2, 2020, Blue Corporation issued $1,850,000 of 10% bonds at 96 due December 31, 2029. Interest on the bonds is payable annually each December 31. The discount on the bonds is also being...
-
What measures are implemented to ensure the integrity and transparency of financial projections, including rigorous validation of underlying assumptions, data integrity checks, and sensitivity to...
-
The following accounting information pertains to Boardwalk Taffy and Beach Sweets. The only difference between the two companies is that Boardwalk Taffy uses FIFO, while Beach Sweets uses LIFO. Cash...
-
How do financial projections incorporate probabilistic modeling and scenario analysis to account for uncertainty and mitigate risk in forecasting future cash flows and performance metrics ?
-
1. Suppose an economy is in long-run equilibrium. Anincrease in consumption expenditure will: ?A. shift the short-run aggregate supply curve rightward andincrease both the price level and real output...
-
Compile data on consumption and expenditures for the following categories in 30 different countries: (1) food and beverages, (2) clothing and footwear, (3) housing and home operations, (4) household...
-
Honda Motor Co. and its subsidiaries (collectively Honda) develop, manufacture, distribute and provide financing for the sale of its motorcycles, automobiles and power products. The consolidated...
-
Why are suppliers and customers interested in studying the financial statements of a company?
-
WPP is a UK group, engaged in the provision of communications services on a national, multinational and global basis. The company is organized into four segments: Advertising and Media Investment...
-
What is the change in velocity of \((a)\) cart 1 (b) cart 2 in Figure 4.6? (c) What do you notice about your two answers? Figure 4.6 Velocity-versus-time graph for two identical carts before and...
-
(a) Are the accelerations of the motions shown in Figure 4.1 constant? (b) For which surface is the acceleration largest in magnitude? Figure 4.1 Velocity-versus-time graph for a wooden block sliding...
-
The \(x\) component of the final velocity of the standard cart in Figure 4.8 is positive. Can you make it negative by adjusting this cart's initial speed while still keeping the half cart initially...
Study smarter with the SolutionInn App