7
I’m looking to make a calculation engine on Python. For example, I have a name program engine.py, that takes an equation and returns the roots. I wanted to write another program named interface.py, that would just take the equation and send it to the engine to calculate and take the returned value. You can do this?
engine py.
x = str(input())
x = x.replace("-","+-")
Eq = list(x.split("+"))
b = 0
c = 0
if "" in Eq: Eq.remove("")
for i in range(0,len(Eq)):
if (Eq[i] == "x²"):
a = 1
elif (Eq[i] == "-x²"):
a = -1
elif "x²" in Eq[i]:
aux = Eq[i]
a = int(aux.replace("x²",""))
elif (Eq[i] == "x"):
b = 1
elif (Eq[i] == "-x"):
b = -1
elif "x" in Eq[i]:
aux = Eq[i]
b = int(aux.replace("x",""))
else:
c = int(Eq[i])
delta = (b * b) - 4 * a * c
print("Delta:",delta)
if delta<0:
print('Essa equacao nao tem raiz real')
elif delta==0:
x1 = (-b)/(2*a)
print('Raiz:',x1)
else:
from math import sqrt
x1 = (-b+sqrt(delta))/(2*a)
x2 = (-b-sqrt(delta))/(2*a)
print('Raizes:')
print("x':",x1)
print("x'':",x2)
Interface.py.
x = input()
y = manda_para_engine(x)
print(x)
something like that
What have you done? click [Edit] and add your code.
– user28595