0

How can I execute an equation with several different symbols in my calculator?

I am making a simple calculator, one that only adds, subtracts,divides, multiplies, finds the square root, and find whatever exponent equation you need. However, I can not figure out how to execute an equation with several different symbols in it, like this one: 4+8-3 How would I incorporate such a feature into my code? If you need to look at it, you can find my current code here: https://code.sololearn.com/c0yoGqbZ5fKx/?ref=app

10th Apr 2018, 11:43 PM
Robyn
2 Answers
+ 4
Python lets you do it shorter in one line print (eval (input())) // sth like that don't remember) But if you want create you own expression counter see SoloLearn's programming tasks. There should be task about your question (and explanations too)
11th Apr 2018, 1:20 AM
Rull Deef đŸș
Rull Deef đŸș - avatar
+ 1
Thank you, Rull Deef. I figured out from another challenge, as you suggested, that in python a calculator requires only one line if code. I feel a little stupid now for writing all that code, but I guess now I know.
11th Apr 2018, 3:01 AM
Robyn