Hey,
I'm trying to make a simple application that should be able to resolve a second degree equation. The script is working but where it should be displayed the result, it's displaying NaN
So, here is the code:
Code:import appuifw from math import sin,cos,tan,sqrt,log op=1 #Calculate while (op!=2): a = float(appuifw.query(u"A:", "number"))#This number should multiply x^2 b = float(appuifw.query(u"B:", "number"))#This number should multiply x c = float(appuifw.query(u"C:", "number"))#This number should be alone #Example: x^2-x-20=0 a:1 b:-1 c:-20 #Delta delta=(pow(b,2))-(4*a*c)#Delta formula if (delta<0): print (u"Delta Negativo") #The equation is impossible #Baskara formula else: x1=((b*-1)+sqrt(delta))/2*a #First possibility for X x2=((b*-1)-sqrt(delta))/2*a #Second possibility for X #The equation is possible continueoption=appuifw.popup_menu([u"%.1f" % (x1), u"%.1f" % (x2), u"Quit"]) if(continueoption==1):op=2
Any ideia of why it's displaying NaN?
I used from base this article:
http://wiki.forum.nokia.com/index.ph...ple_calculator
Any help will be very useful.
Thanks!!!


Reply With Quote


