python 3.x - Complete Algebraic Equations -


im trying build app graphs equation based on user input. equation in slope intercept form: y = mx + b, m slope , b y intercept. however, isn't working me in python!

i tried this:

>>> x = 3 >>> 1/2x 

and returned this:

  file "<stdin>", line 1     1/2x        ^ syntaxerror: invalid syntax >>> 

how make returns 1.5?

import re mxb = re.compile('''(?p<slope>[(\d)/.]*)x\s+(?p<sign>[+-])\s+(?p<intercept>[\d./]*)''') s = '1/2x + 5'  match = mxb.match(s) if match :      print( match.groupdict() ) 

test python regex here : pythex.org


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -