0

Here's my guess:

TempFunc1 = input('Eqution1: ')
TempFunc2 = input('Eqution2: ')
TempFunc3 = eval(TempFunc1/TempFunc2)

I have defined x as a symbol and enter x**2-4 for Equation1 and x-2 for the other. And I Have imported * from sympy. the whole code:

import os
from sympy import *
from random import randrange
x = Symbol('x')
Variable = input('Eqution: ')
TempFunc1 = Variable.translate(str.maketrans('abcdefghijklmnopqrstuvwyz','xxxxxxxxxxxxxxxxxxxxxxxxx'))
TempFunc2 = TempFunc1.replace('^', '**')
TempFunc3 = input('Eqution: ')
TempFunc4 = eval(TempFunc2/eval(TempFunc3)
Func = eval(TempFunc4)
Func_prime = Func.diff(x)
Func = lambdify(x, Func)
Func_prime = lambdify(x, Func_prime)
x = randrange(100)
print('attempts:')

while Func(x) != 0:
  Derivative = Func_prime(x)
  Function = Func(x)
  Divide = Function/Derivative
  x = x-Divide
  print(x)
else:
  Ans = round( x , 31  )
  print("answer:")
  print(Ans)
  os.system('pause')

0 Answers0