Menu

Python question / help

Davey
2014-07-09
2014-07-10
  • Davey

    Davey - 2014-07-09

    Hi
    Fairly new to python...
    I have a user typing a string like this:
    1000 / 2 * 5 + 616

    Is there an easy way to get the result of this equation in python?

    Thanks
    Davey

    ===============================
    In totality, this is what I am trying to do:
    I have text as seen below and I would like to get the final result after the loop
    If anyone can help guide me in this I would really appreciate it.

    RegistNum[q+=1]:=1000 / 2 * 5 + 616
    RegistNum[q+=1]:=89 * 987 - 84615
    RegistNum[q+=1]:=898 * 7 - 2141
    RegistNum[q+=1]:=200 * 10 / 2 + 3093
    RegistNum[q+=1]:=q
    amt:=RegistNum[q], j:=21867

    for i:=1 to amt do
    sum += RegistNum[i](i52) / (26 * (q/2))
    end for

     
  • Davey

    Davey - 2014-07-10

    Hi guys
    I figured it out
    to get the result of a mathematical equation in string form, use eval
    s = "3 * 8 - 99 / 3"
    eval(s) - will return the result of that mathematical eq