我在用python求解二次公式时犯了一个错误

我在用python求解二次公式时犯了一个错误,python,Python,我是python的初学者,有人能帮我一下我做错了什么吗 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 = inp

我是python的初学者,有人能帮我一下我做错了什么吗

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")
以下是控制台中显示的内容: 我应该在函数中使用不同的变量名,还是应该使用不同的变量名

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'
TypeError回溯(最近一次调用)
在里面
12 c=输入(“输入c”)
13
--->14.李冲(a、b、c)
15
16份印刷品(f“第二方印刷品(loesung1}和{loesung2}!\n))
李冲(a、b、c)
3.
四、李冲(甲、乙、丙):
---->5乐声1=-(b/a)/2+sqrt(((b/a)/2)*((b/a)/2)-(c/a))
6乐声2=-(b/a)/2-sqrt(((b/a)/2)*((b/a)/2)-(c/a))
7.
TypeError:/:“str”和“str”的操作数类型不受支持

提前谢谢

仅通过查看错误,变量
a
b
c
看起来像是作为字符串发送的。然后,您的
quadragleichung
方法正在尝试划分字符串类型,但它无法做到这一点。
在调用
quadragleichung


a=float(输入(“输入a”)
b
c

这是否回答了您的问题?此外,使用
sqrt
而不是
math.sqrt
是导入语句的问题,尽管您可以使用math import sqrt