#!/usr/bin/env python
from math import sqrt
def Calculo(X,Y,Z):
try:
N1 = (-Y + ((sqrt((Y*Y) - (4*X*Z)))/(2*X)))
N2 = (-Y - ((sqrt((Y*Y) - (4*X*Z)))/(2*X)))
return "(+) = " + str(N1) + "(-) = " + str(N2)
except:
return 'Sin solucion, intenta nuevamente'
while True:
print "Ecuacion:"
X = input(' X = ')
Y = input(' Y = ')
Z = input(' Z = ')
print Calculo(X,Y,Z)
Luego de años sin practicar, no viene mal retomar las mañas...
Saludos!
Muy bueno brother, sólo un par de observaciones:
1) Como estás importando con from math import sqrt no accedes a la función con math.sqrt() sino que lo haces sólo con sqrt().
2) Si evaluas el discriminante te puedes ahorrar el try:
Saludos!
Muy bueno!!! Espero nuevos aportes!!