<p>有人能告诉我为什么我会犯这个错误吗?你知道吗</p>
<pre><code>Traceback (most recent call last):
File "file.py", line 14, in <module>
p2 = math.sqrt(b*b -4*a*c)
ValueError: math domain error
</code></pre>
<p>我是一个新手编码,所以需要一些帮助:)</p>
<p>我的代码如下所示:</p>
<pre><code># -*- coding: utf-8 -*-
a = input("¿Qué valor es a?")
while(str(a).isdigit() != True):
a = input("Porfavor, introduce un número para a, no un texto")
b = input("¿Qué valor es b?")
while(str(b).isdigit() != True):
b = input("Porfavor, introduce un número para b, no un texto")
c = input("¿Qué valor es c?")
while(str(c).isdigit() != True):
c = input("Porfavor, introduce un número para c, no un texto")
import math
p1 = b * -1
p2 = math.sqrt(b*b -4*a*c)
p3 = 2*a
s1 = (p1+p2)/p3
s2 = (p1-p2)/p3
print("Soluciones :", s1, " y ", s2)
</code></pre>