Answer
$f(x)=\begin{cases} \ \ \ 2,\ x\le 0 \\ -1,\ x\gt 1\end{cases}$
domain $(-\infty,0]U(1,\infty)$ and range $\{-1,2 \}$
Work Step by Step
Step 1. Identify the left line equation as $y=2$ with $x\le 0$.
Step 2. Identify the right line equation as $y=-1$ with $x\gt 1$.
Step 3. Combine the above to get: $f(x)=\begin{cases} \ \ \ 2,\ x\le 0 \\ -1,\ x\gt 1\end{cases}$
Step 4. Identify the domain as $(-\infty,0]U(1,\infty)$ and range as $\{-1,2 \}$