im a beginner in python, can somebody help me what i did wrong here?
import math def quadratgleichung(a,b,c): loesung1 = - (b/a)/2 + sqrt( ((b/a)/2) * ((b/a)/2) - (c/a) ) loesung2 = - (b/a)/2 - sqrt( ((b/a)/2) * ((b/a)/2) - (c/a) ) return loesung1, loesung2 a = input("Enter a.") b = input("Enter b.") c = input("Enter c.") quadratgleichung(a,b,c) print(f"Die Lösungen der eingegebenen quadratischen Gleichung sind {loesung1} und {loesung2} !\n") this is what comes out in the console: should i use different variable names in the function or were is the problem?
TypeError Traceback (most recent call last) <ipython-input-11-3207ceaf35b6> in <module> 12 c = input("Enter c.") 13 ---> 14 quadratgleichung(a,b,c) 15 16 print(f"Die Lösungen der eingegebenen quadratischen Gleichung sind {loesung1} und {loesung2} !\n") <ipython-input-11-3207ceaf35b6> in quadratgleichung(a, b, c) 3 4 def quadratgleichung(a,b,c): ----> 5 loesung1 = - (b/a)/2 + sqrt(((b/a)/2) * ((b/a)/2) - (c/a)) 6 loesung2 = - (b/a)/2 - sqrt(((b/a)/2) * ((b/a)/2) - (c/a)) 7 TypeError: unsupported operand type(s) for /: 'str' and 'str' thanks in advance!!
sqrtrather thanmath.sqrtis a problem given your import statement, though you could usefrom math import sqrt