Description: 计算下列分段函数f(x)的值:
f(x) | x |
---|---|
1/x | x ≠ 0 |
0 | x = 0 |
Input: 输入仅一行,输入一个实数x。
Output: 输出仅一行,按“f(x) = result”的格式输出,其中x与result都保留一位小数。
Sample Input: 10
Sample Output: f(10.0) = 0.1
Sample Input: 0
Sample Output: f(0.0) = 0.0
x = input()
x = float(x)
if x == 0:
result = 0
else:
result = 1 / x
print("f(%.1f) = " % x + "%.1f" % result)