+ 1

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..

27th Nov 2019, 5:20 PM
kianoush
kianoush - avatar
2 odpowiedzi
+ 3
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
27th Nov 2019, 5:28 PM
id001x
id001x - avatar
+ 3
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
28th Nov 2019, 12:08 AM
Faisal
Faisal - avatar