Can someone tell me why am I getting this error?
Traceback (most recent call last):
File "file.py", line 14, in <module>
p2 = math.sqrt(b*b -4*a*c)
ValueError: math domain error
I'm a newbie coding, so need some help :)
My code looks like this:
# -*- 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)