I came up with this answer in stackoverflow. It states a question:
Given that Pi can be estimated using the function 4 * (1 - 1/3 + 1/5 - 1/7 + ...)
with more terms giving greater accuracy, write a function that calculates Pi to
an accuracy of 5 decimal places.
I once knew how to do things like that but now it is all white space in my brains. Moreover, I cannot figure out what to google for so I get the needed algorithm. This link, however, tells it is using a graph calculator, which isn't helpful at all.
First of all, this is a terrible way to compute $\pi$. That said, you have a series satisfying the hypotheses of the alternating series test. In particular this means that
$$ \left| \pi - 4\sum_{k=0}^n \frac{(-1)^k}{2k+1} \right| < \frac{4}{2n+3}, $$ i.e. the error in the approximation is less than the first omitted term. (This is not true for general series!)
If you want five correct decimal places, you need to guarantee that the error is less than $5\times 10^{-6}$, so you want to choose $n$ such that
$$ \frac{4}{2n+3} < 5\times 10^{-6} \quad\Rightarrow\quad n > 399,999. $$
I'll leave the actual implementation as a suitable loop up to you. If you don't want to do the computatation of $n$ beforehand, just loop until the next term is small enough. Again, this approach relies on the alternating series test.