# piecewise defined function via def

I've made the following experiment with Sage:

```
def f(x):
if (0<= x<= 1/2):
return 1
else:
return 0
assume(0<= x<= 1/2)
show(f(x))
show(f(1/3))
```

However I get outputs 0 and 1 respectively. Can someone clarify please? Thanks.

Sometimes one should constrain sage to evaluate...

This gives:

Note: duplicate of https://ask.sagemath.org/question/410...