#C3883. Basic Calculator
Basic Calculator
Basic Calculator
This problem requires you to implement a basic calculator that performs simple arithmetic operations. You will be given two numbers and an operator. The operator can be one of the following: + (addition), - (subtraction), * (multiplication), or / (division). The operation is defined mathematically as follows:
\(a \; \text{operator} \; b\)
If the operator is /
and b is 0, then the output should be None. If the operator is invalid (i.e. not one of +
, -
, *
, or /
), then output exactly Invalid operator.
Note: The result of a valid operation should always be printed as a floating-point number with one decimal point (e.g. 5.0).
inputFormat
The input consists of a single line containing two floating-point numbers and an operator separated by spaces.
For example: 2 + 3
outputFormat
Output the result of the arithmetic operation as a floating-point number with one decimal precision. If a division by zero occurs, output None
. If the operator is invalid, output Invalid operator
.
2 + 3
5.0
</p>