compactness and boundedness 
Let X be a compact metric space. Show that a continuous function $f:X\rightarrow\mathbb{R}$ is bounded.

Attempt: So compact $\implies$ closed and bounded, but it is not always the case that if $A$ is bounded that $f(A)$ is bounded. So I think I need to show that $X$ compact $\implies$ $\exists M\in\mathbb{R}$ : $|f(x)|\leq M$ (definition of a bounded function). Maybe letting $M=\sup(X)$ would work? I'm just not sure that I'm allowed to take a $\sup$ of an arbitrary metric space.
 A: The image of a compact set under a continuous map is compact. All compact sets in $\mathbb{R}$ are bounded. QED.
A: You can do this without using the fact that $f(X)$ is compact (though it does need the result that compactness implies sequential compactness in metric spaces):
If $f$ is not bounded, then there is a sequence $(x_n)_n$ in $X$ with 
$$\tag{1}|f(x_n)|>n,\quad\text{ for each }n=1,2,\ldots.$$
Since $X$ is compact, there is a subsequence $(x_{n_k})_k$ that converges to $x\in X$. 
Now, by $(1)$, it follows that $f(x_{n_k})$ does not converge to $f(x)$; which implies that $f$ is not continuous on $X$.

Or, you could argue as follows:
Consider the open balls $O_n=\{ y\in \Bbb R: |y|<n\}$ in $\Bbb R$. Then, since $f$ is continuous, $\{ f^{-1}(O_n): n=1,2,\ldots\}$ is an open cover of $X$. Since $X$ is compact, and since $f^{-1}(O_m)\subset f^{-1}(O_n)$ whenever $n>m$, there is an $N$ so that $f^{-1}(O_N)$ covers $X$. This implies that $f$ is bounded.
I prefer the latter argument, as a  modification could be made to prove that the continuous image of a compact set  is compact.
A: Your definition of compactness (closed and bounded) works for $\Bbb{R}$ and $\Bbb{R}^n$ (and other finite dimensional spaces), but it is not the general definition. 

In a topological space $X$, a set $K$ is said to be compact if from any open cover ${O_\alpha}$ of $X$ (i.e. $O_\alpha$ are open set, and their union covers $K$) we can extract a finite subcover (i.e. we can choose a finite number of open sets from the initial cover, which still covers $K$).

Using this definition it is rather easy to prove that the image of a compact set through a continuous function remains compact.
So you have $f: X \to \Bbb{R}$, and $X$ is compact. Pick an open  cover $(O_\alpha)$ for $f(X)$ (the image of $X$ under $f$). Then $(f^{-1}(O_\alpha))$ is an open cover for $X$. 
$X$ is compact, so we can extract a finite subcover $(f^{-1}(O_k))_{k=1}^n$. From here it follows that $(O_k)_{k=1}^n$ covers $f(X)$, so we have found a finite subcover.
A: David Mitra has already said this, but it is worth saying it more explicitly, because it is a prototypical use of compactness. For each $n \in \mathbb{N}$ let $A_n$ be $f^{-1}(-n,n)$, the inverse image of the interval $(-n,n)$. This is an open cover of $X$: open because $f$ is continuous and a cover because $\mathbb{R}$ is Archimedian.  Thus the cover has a finite subcover $F$. Let $m$ be maximal such that $A_m \in F$. Then $f$ is bounded by $m$. 
