PROGRAMMING:Calculating piecewise functions
This topic requires the calculation of the following piecewise function g (x)
$$ g(x)= \begin{cases}0& \text{x=0}\\ \frac{1}{2x}& \text{x!= 0} \end{cases} $$
###Input format:
Enter the real number x on one line.
###Output format:
Output in the format of "g (x) = result" in one line, where both X and result retain 3 decimal places.
###Input sample 1:
Here is a set of inputs. For example:
```in
five hundred
```
###Output sample 1:
The corresponding output is given here. For example:
```out
g(500.000) = 0.001
```
###Input sample 2:
Here is a set of inputs. For example:
```in
0
```
###Output sample 2:
The corresponding output is given here. For example:
```out
g(0.000) = 0.000
```
answer:If there is no answer, please comment
```
x=float(input())
if int(x)!= 0:
y=1/(2*x)
else:
y=0
print("g({0:.3f}) = {1:.3f}".format(x,y))
```
$$ g(x)= \begin{cases}0& \text{x=0}\\ \frac{1}{2x}& \text{x!= 0} \end{cases} $$
###Input format:
Enter the real number x on one line.
###Output format:
Output in the format of "g (x) = result" in one line, where both X and result retain 3 decimal places.
###Input sample 1:
Here is a set of inputs. For example:
```in
five hundred
```
###Output sample 1:
The corresponding output is given here. For example:
```out
g(500.000) = 0.001
```
###Input sample 2:
Here is a set of inputs. For example:
```in
0
```
###Output sample 2:
The corresponding output is given here. For example:
```out
g(0.000) = 0.000
```
answer:If there is no answer, please comment
```
x=float(input())
if int(x)!= 0:
y=1/(2*x)
else:
y=0
print("g({0:.3f}) = {1:.3f}".format(x,y))
```