Muchas gracias
Código Python:
Ver original
def complejos (d,k): if d==0 and k==0: print(0) elif d==0 and k==1: print("i") elif d==0 and k==-1: print("-i") elif d==0 and k!=0: print(str(k) + "i") elif d!=0 and k==0: print(d) elif k==-1: print (str(d) + "-" + "i") elif k<-1: print (str(d)+ str(k)+"i") elif k==1: print (str(d) + "+" + "i") elif k>1: print (str(d)+ "+" + str(k)+"i") else: print (str(d) + str(k) + "i") import math a= input=2 b= input=2 c= input=1 if a==0: print("no es una ecuacion de segundo grado") else: m=b**2-4*a*c if m==0: print(-b/(2*a)) elif m<0: "x1=complejos(-b/(2*a), (math.sqrt(m)) / 2*a )" "x2=complejos(-b/(2*a), (math.sqrt(m)) / 2*a )" else: "x1=(str(-b)+'+'+math.sqrt(m))/(2*a)" "x2=(str(-b)+'-'+math.sqrt(m))/(2*a)"