GH avatar Bite 159. Create a simple calculator

In this Bite you will create a simple calculator. It takes a string of num1 operator num2 which you convert into its calculation returning its result. Complete simple_calculator to that end supporting +, -, * and / ("true" division so 2/3 = .66 rather than 0).

So passing '2 * 3' into the function it would return 6, '2 + 6' results in 8, '-5 * -11' = 55 and lastly '1 / 5' = 0.20.

For any bad data passed into the function (e.g. a / 3, 2 * b, 1 ^ 2, etc), you should raise a ValueError.

Good luck and have fun!

Will you be Pythonista #28 to crack this Bite?
It takes an average of ~27 minutes to solve this Bite (submissions 5-240 min).
Pythonistas rate this Bite 3.0 on a 1-10 difficulty scale.
» You can do it! 😌

Buy Now Login and get coding
We use Python 3.7