12.07.2015 Views

Think Python - Denison University

Think Python - Denison University

Think Python - Denison University

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

70 Chapter 7. IterationWrite a function called estimate_pi that uses this formula to compute and return an estimate ofπ. It should use a while loop to compute terms of the summation until the last term is smaller than1e-15(which is<strong>Python</strong> notation for 10 −15 ). You can check theresult bycomparing it tomath.pi.You can see mysolutionatthinkpython.com/code/pi.py.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!