#C9186. Evaluate Arithmetic Expression
Evaluate Arithmetic Expression
Evaluate Arithmetic Expression
You are given a simple arithmetic expression in the form of \(term\; operator\; term\). The two terms can be integers or decimals and the operator can be one of the following: \(+\), \(-\), \(\times\) (asterisk *
), or \(\div\) (slash /
). When performing division by zero, output None
.
The result should be printed as an integer if it has no fractional part; otherwise, it should be printed as a floating-point number.
inputFormat
The input is provided from stdin as a single line containing the expression in the format:
term operator term
Examples:
3 + 5 10.5 / 2.0
outputFormat
Output the evaluated result to stdout. If division by zero occurs, output None
. If the result is a whole number, output it as an integer; otherwise as a floating-point number.
3 + 5
8