Question
In python: I have this so far but not sure how to get it to work or incorporate the positive and negative equation to it.
In python:
I have this so far but not sure how to get it to work or incorporate the positive and negative equation to it.
def positive(value): if value > 0: return value if value < 0: return value * -1 else: return 0
def plusRoot(a, b, c): d = (b**2) - (4*a*c) solve1 = (-b + math.sqrt(d))/(2*a) solve2 = (-b - math.sqrt(d))/(2*a) return solve1, solve2
thenum = plusRoot(1, 2, 1) print(plusRoot)
Write a function called plusRoot that accepts three numbers (a,b,c). It should then find and return the root of the equation ax
2 + bx + c = 0 using the positive version of the
quadaratic formula: x1 =
b+b24ac 2a .
Then write the pair function called negRoot that accepts three numbers (a,b,c) and finds and prints the 2nd root using the negative version of the quadratic. x2 = b+b^24ac/2a.
Then in your main program show that you program works by finding the roots of the two equations below, catching the result and printing out the results.
1x^2 2x 35 = 0
Answers should be 7 and -5.
4x^2 24x + 35
Answers should be 2.5 and 3.5.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started