Calculate mathmatical String | Sololearn: Learn to code for FREE!


Calculate mathmatical String

Hi guys. I want to give String like "3+(4**14-13//16)" and calculate it. Notice:the input is changable and it's not fixed... I want write this in python or java... Thank's for helping..

11/27/2019 5:20:35 PM


2 Answers

New Answer


You must parse your string to arguments and operators. Then you must find privileged instructions like */() and other. And only after this you can calculate it


If you're looking to do that in Python, you could do so by using the eval() function as it reads a string as if it were a line of code