avisrivastava254084

Untitled

Nov 21st, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.25 KB | None | 0 0
  1. import random
  2. import parser
  3.  
  4. equation_ = '(x**3 + 5*(x**2) - 3*x + 3) + (4*(x**5) - 2*(x**2) + 1)'
  5.  
  6. code = parser.expr(equation_).compile()
  7. test_cases = [random.randrange(-100, 100) for _ in range(10)]
  8.  
  9. for x in test_cases:
  10.     print(eval(code))
Add Comment
Please, Sign In to add comment