本题目要求计算以下分段函数的值(x为从键盘输入的一个任意实数):

如果输入非数字,则输出“Input Error!”
在一行中输入一个实数x。
在一行中按”y=result”的格式输出,其中result保留两位小数。
-2
在这里给出相应的输出。例如:
y=3.00def demo1(x):
    if x > 1:
        y = 2 * x + 1
    elif x > -2:
        y = 3
    else:
        y = -2 * x - 1
    print("y={:.2f}".format(y))
try:
    x = eval(input())
    demo1(x)
except Exception as result:
    print("Input Error!")
原文:https://www.cnblogs.com/aimilu/p/11819121.html