<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _constrain(value, lb=0, ub=1):
 """Helper for Color constructors. Constrains a value to a range."""

    if value < lb:
        return lb
    elif value > ub:
        return ub
    else:
        return value