+ 1

Calculator for python robot

How could I add a calculator to my python robot with this input x + y (add) x - y (subtract) x * y (multiply) x / y (divide) https://code.sololearn.com/cGBTjfDicqdd/?ref=app

26th Nov 2021, 2:18 AM
експоненти
експоненти - avatar
5 Answers
+ 1
Like, you want the user to input "5+5" and detect that's addition and output the answer? If that's the case, use "eval" function, it'll be a good choice Or if you're trying to advertise your code(cuz it's a very simple thing for a person who coded a communicating Robot), it's strictly prohibited in this forum
26th Nov 2021, 2:40 AM
Rishi
Rishi - avatar
+ 1
Rishi ive tried using an eval function but it needs to be set to function by the user input because there are other commands
26th Nov 2021, 12:44 PM
експоненти
експоненти - avatar
+ 1
Rishi i would have to write it as if it is an equation than print eval but idk how to do that
26th Nov 2021, 12:45 PM
експоненти
експоненти - avatar
+ 1
exonits well in that case I too don't have an idea, I think let's wait for someone with an idea to answer :)
26th Nov 2021, 4:07 PM
Rishi
Rishi - avatar
+ 1
26th Nov 2021, 5:06 PM
експоненти
експоненти - avatar