Answer
See graph.
Work Step by Step
Step 1. It takes $\frac{20}{40}=0.5\ hr$ to the park, thus during $0\le x \le 0.5$, we have $f(x)=40x$ where $x$ is the time in hour, $f(x)$ is the distance from home.
Step 2. Remain at the park for 2 hrs means $f(x)=20$ for $0.5\lt x \le 2.5$
Step 3. It takes $\frac{20}{20}=1\ hr$ back from the park, thus during $2.5\lt x \le 3.5$, we have $f(x)=20-20(x-2.5)$
Step 4. Combine the above results, we have $f(x)=\begin{cases} 40x,\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0\le x \le 0.5\\ 20,\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 0.5\lt x \le 2.5 \\ 20-20(x-2.5),\ 2.5\lt x \le 3.5 \end{cases}$
Step 5. We can graph the above function as shown in the figure.