那个啥 图片照错了 题目里面没有说要用 “%f” 求给个不用"%f"的码。
"Your code will be provided an unknown value for x. (That is, don't specify x yourself.)
Write an if/elif/else statement which implements this piecewise expression and prints the result in the format 'x N'. Assume that the provided value is called x."
我写的代码如下:
if x < -1:
x_N = 0
print (x_N)
elif x>= -1 & x<=0 :
x_N = 1+x
print (x_N)
elif x>= 0 & x<=1 :
x_N = 1-x
print (x_N)
else:
x_N = 0
print (x_N)