Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import parser
- equation_ = '(x**3 + 5*(x**2) - 3*x + 3) + (4*(x**5) - 2*(x**2) + 1)'
- code = parser.expr(equation_).compile()
- test_cases = [random.randrange(-100, 100) for _ in range(10)]
- for x in test_cases:
- print(eval(code))
Add Comment
Please, Sign In to add comment