+ 1
Pls someone should guide me on how to go about writing quadratic equation using PERMDAS with python
Quadratic equation(Top urgent)
3 Answers
+ 1
Show us your work so far, and we can help. If you've got nothing, get to work.
+ 1
To write a quadratic equation using the PERMDAS (Parentheses, Exponents, Multiplication and Division, Addition and Subtraction) principle in Python, you can use the following code:
import math
def quadratic_equation(a, b, c):
x1 = (-b + math.sqrt(b**2 - 4*a*c)) / (2*a)
x2 = (-b - math.sqrt(b**2 - 4*a*c)) / (2*a)
return x1, x2
# Example
a = 1
b = -3
c = 2
result = quadratic_equation(a, b, c)
print("The solutions of the quadratic equation are:", result)
In this code, the quadratic_equation function uses the formula (-b ± â(bÂČ - 4ac)) / 2a to calculate the two solutions of the quadratic equation. The math.sqrt() function is used to calculate the square root. The result is returned as a tuple and then printed.
Please note that the variable a should not be zero, as it would lead to division by zero.
0
Thank you