Let $(X,d)$ be a metric space with the property that for every continuous function $f : X \to \mathbb{R}$ it satisfies property P:
Property P: For every $\epsilon >0$ there exists $\delta >0$ such that if $A \subseteq X$ is such that $diam(A)<\delta$ then there exists a finite $B \subseteq \mathbb{R}$ such that for every $a \in A$ there exists $b \in B$ such that $f(a) \in (b-\epsilon, b + \epsilon)$.
Prove:
(1) That every closed subspace $Y \subseteq X$ has property P.
(2) X is complete.
I managed to solve two additional sub-exercises which are:
(i) If the codomain was some other metric space $Y$ instead of $\mathbb{R}$, then every cauchy sequence in $X$ maps to a sequence in $Y$ that has a cauchy subsequence.
(ii) Given any continuous $f : X \to \mathbb{R}$, and $\epsilon>0$ the open cover $\{f^{-1}((q-\epsilon,q+\epsilon)):q\in\mathbb{Q}\}$ has a weak lebesgue number.
But I'm not able to leverage them to solve either of the above.
I am especially confused about (1) above. It seems to me that the only way you could prove it is to extend an arbitrary continuous function $f: Y \to \mathbb{R}$ to some continuous function on $X$, but I'm pretty sure that can't be done unless you have some additional assumptions on $X$ like normality.
(1) Let $Y \subset X$ be closed and $f : Y \to \mathbb R$ be continuous. Since metric spaces are normal, the Tietze extension theorem gives a continuous map $F : X \to \mathbb R$ extending $f$. Given $\epsilon > 0$, choose $\delta > 0$ for $F$ as in property P. Cearly this $\delta$ does for $f$.
(2) Assume $(X,d)$ is not complete. Then there exists a Cauchy sequence $(x_n)$ which does not converge. Thus also no subsequence of $(x_n)$ converges.
The set $Y = \{ x_n \mid n \in \mathbb N \}$ is infinite (otherwise we could find a constant subsequence of $(x_n)$, and this trivially converges). Moreover, $Y$ does not have a cluster point in $X$: Let $y \in X$ and assume that for each $m \in \mathbb N$ there exists $y_m \in Y \setminus \{y\}$ such that $d(y,y_m) < 1/m$. Then we can construct a subsequence of $(x_n)$ converging to $y$. Hence $Y$ is a closed discrete subset of $X$.
We can write $Y = \{y_k \mid k \in \mathbb N\}$ with $y_k \ne y_l $ for $k \ne l$. Now define $f : Y \to \mathbb R, f(y_k) = k$. This is a continuous function which does not have property P. This contradicts (1).