Python error: SyntaxError in elif statement: invalid syntax

Asked 2 years ago, Updated 2 years ago, 16 views

import math

a = int (input ("factor of x의: ")))
b = int (input ("factor of x: ")))
c = int (input ("constant term: ")))

if (-1*b + math.sqrt(abs((b*b) - (4*a*c)))) / (a*2) % 1 != 0 or (-1*b - math.sqrt(abs((b*b) - (4*a*c)))) / (a*2) % 1 != 0:
    print ("the solution of the following quadratic equations is: \n", -1*b, "±",", b*b, "-", 4*a*c, "/", 2*a, "/", "(, 2*a, "min", -1*b, "±",", b*b, "-", 4*a*c, "", "", "\n, approximately") 
    if (-1*b + math.sqrt(abs((b*b) - (4*a*c)))) / (a*2) == (-1*b - math.sqrt(abs((b*b) - (4*a*c)))) / (a*2):
        print((-1*b + math.sqrt(abs((b*b) -(4*a*c))))) / (a*2), "\n has a middle root.")
    else:
        print((-1*b + math.sqrt(abs((b*b) - (4*a*c))))) / (a*2), "\n or\n", (-1*b - math).sqrt(abs((b*b) -         (4*a*c))) / (a*2))

elif (-1*b + math.sqrt((b*b) - (4*a*c))) / (a*2) != (-1*b - math.sqrt((b*b) - (4*a*c))) / (a*2):
    print("Solution of the following quadratic equation: \n", (-1*b + math.sqrt((b*b) - (4*a*c))) / (a*2), "\n or\n", (-1*b - math).sqrt((b*b) - (4*a*c))) / (a*2))

elif (-1*b + math.sqrt((b*b) - (4*a*c))) / (a*2) == (-1*b - math.sqrt((b*b) - (4*a*c))) / (a*2):
    print("Solution of the following quadratic equation: \n", (-1*b + math.sqrt((b*b) - (4*a*c))) / (a*2), "\n has a medium muscle.")

I made the code like this.

Makefile:6:recipe for target 'py3_run' failed
make: *** [py3_run] Error 1
  File "/goorm/Main.out", line 18
    if (-1*b + math.sqrt((b*b) - (4*a*c))) / (a*2) != (-1*b - math.sqrt((b*b) - (4*a*c))) / (a*2):
                                                                                                 ^
SyntaxError: invalid syntax

There's an error like this. Is there a solution? It's a code woven from the clouds.

python

2022-09-20 15:17

1 Answers

The print door in the front row lacks parentheses.


2022-09-20 15:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.