×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Super Contributor
    Join Date
    Feb 2008
    Location
    Belo Horizonte, Brazil
    Posts
    744

    Exclamation Problems using Math Module

    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!!!

  2. #2
    Super Contributor
    Join Date
    Feb 2008
    Location
    Belo Horizonte, Brazil
    Posts
    744

    Re: Problems using Math Module

    Problem Solved =)

  3. #3
    Regular Contributor
    Join Date
    Dec 2007
    Location
    Tempe, AZ
    Posts
    411

    Re: Problems using Math Module

    Hey Rafael T. please tell how did you solve the problem, so that it can be handy for me and everyone if someone encounters same problem.
    IDEAS is all they need but still they think only Genius can give them that.

  4. #4
    Super Contributor
    Join Date
    Feb 2008
    Location
    Belo Horizonte, Brazil
    Posts
    744

    Re: Problems using Math Module

    I solved by using A,B and C as a text instead of number ... so it can be negative!

Similar Threads

  1. Problems about maemo 4.0.1 SDK installation.
    By fgg_maemo in forum General Development Questions
    Replies: 3
    Last Post: 2008-10-07, 14:26
  2. Carbide.j 1.5 and Netbeans 5.5 beta 2
    By ovjo12 in forum Mobile Java Tools & SDKs
    Replies: 5
    Last Post: 2007-06-11, 05:43
  3. Replies: 1
    Last Post: 2006-11-23, 17:57
  4. Problems with errno module
    By tsharju in forum Python
    Replies: 1
    Last Post: 2005-10-21, 11:24
  5. Replies: 1
    Last Post: 2002-12-16, 12:33

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •