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