Proving that $S=\{\frac{1}{n}:n\in\mathbb{Z}\}\cup\{0\}$ is compact using the open cover definition
Let $S=\{0\}\cup \{\frac{1}{n}:n\in\mathbb{N}\}$. We wish to prove that $S$ is a compact subset of $\mathbb{R}$. The following exercises will lead you to not only an answer to your question but will also develop your intuitions about compactness.
You should do Exercise 1 because the technique that you will use to solve it is identical to the technique that you will use to find the answer to your question using Srivatsan's comment above.
Exercise 1: Let $F$ be a finite subset of $\mathbb{R}$. Prove that $F$ is compact. (Hint: this is easy but if you get stuck, then think about how to prove a singleton set is compact, a two-element set is compact etc. until you get the idea of how to approach the general case.)
The following exercise is important because it makes precise the key idea that the element $0\in S$ is crucial to the compactness of $S$. You can then rigorously pinpoint this idea to develop a formal proof.
Exercise 2: Prove that the set $T=\{\frac{1}{n}:n\in\mathbb{N}\}$ is not a compact subset of $\mathbb{R}$. In particular, if we wish to prove that your subset $S$ of $\mathbb{R}$ is compact, then we need to carefully study the behavior of open covers of $S$ in relation to $0\in S$. (Hint: if $n$ is a positive integer, then choose an open interval $U_n$ in $\mathbb{R}$ such that $\frac{1}{n}\in U_n$ but $\frac{1}{m}\not\in U_n$ for all positive integers $m\neq n$. Prove that $\{U_n\}_{n\in\mathbb{N}}$ is an open cover of $S$ with no finite subcover.)
The following exercise will not be used in the answer to your question but it is recommended that you think about how to solve it because it subsumes an important intuition that is relevant to your question.
Exercise 3 (Optional): Let $K_1$ and $K_2$ be compact subsets of $\mathbb{R}$. Prove that $K_1\cup K_2$ is a compact subset of $\mathbb{R}$. Deduce that a finite union of compact subsets of $\mathbb{R}$ is a compact subset of $\mathbb{R}$ (by induction).
The following exercise is also very relevant to your question and you should know how to solve it:
Exercise 4: Prove the following results about sequences in $\mathbb{R}$:
(a) the sequence $\{\frac{1}{n}\}_{n\in\mathbb{N}}$ converges to $0$ in $\mathbb{R}$;
(b) if $\{s_n\}_{n\in\mathbb{N}}$ is a convergent sequence in $\mathbb{R}$ with limit $s$, then every neighborhood of $s$ contains all but finitely many terms of the sequence $\{s_n\}_{n\in\mathbb{N}}$.
Let us now finally prove that $S$ is a compact subset of $\mathbb{R}$. We need to think about the role played by the element $0\in S$ by Exercise 2. If $\{U_{\alpha}\}_{\alpha\in A}$ is an open cover of $S$ where $A$ is an index set, then there exists an index $a\in A$ such that $0\in U_a$.
Exercise 5: Note that $U_a$ contains all but finitely many elements of $S$ by Exercise 4. The idea used to solve Exercise 1 will allow you to find a finite subcover of $S$. (Hint: $U_a$ should be an element of this finite subcover.)
I hope this helps!