The interact gives the error message "TypeError: unsupported operand type(s) for *: 'DiscreteSlider' and 'sage.symbolic.expression.Expression'" when the slider is moved?
@interact def piecewise(fx = selector(values=["Two Pieces","Three Pieces"],label="Select Number of Pieces"),
base = slider(vmin=10,vmax=200,step_size=10,default=30,label = "Base Rate = "),
c1= slider(vmin=0.1,vmax=1,step_size=0.1,default=0.6,label="charge_per_unit_tier1 = "),
cd1=slider(vmin=100,vmax=1000,step_size=10,default=700,label="condition_tier1 = "),
c2 = slider(vmin=0.1,vmax=1,step_size=0.1,default=0.9,label="charge_per_unit_tier2 = ")):
f = piecewise( [ [(0,cd1),base+c1*x], [(cd1,1000),base+c1*cd1+c2*(x-cd1) ]] )
show(plot(f,(x,0,1000)),gridlines="minor")
add a comment