Two numbers, one operator (Calculator)
Each line is a op b with spaces around the operator, where op is + - /. Print the result. Whole results print with no decimal point (7); others with up to 6 decimals and no trailing zeros (3.5, 0.333333). Dividing by zero prints Error: division by zero; any other line prints Error: bad expression.
Input: One calculation per line.
Output: One result per line.
Difficulty: Easy. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.
Hint
- Parse the two numbers as decimals.